pyuaf.client.settings
¶
class ServiceSettings¶
-
class
pyuaf.client.settings.
ServiceSettings
(*args)¶ A ServiceSettings object is the superclass of
ReadSettings
,WriteSettings
, etc.Methods:
Attributes
-
callTimeoutSec
¶ The maximum time allowed for each service communication between client and server, in seconds, as a
float
.
-
class BrowseNextSettings¶
-
class
pyuaf.client.settings.
BrowseNextSettings
(*args)¶ A BrowseNextSettings is a subclass of
pyuaf.client.settings.ServiceSettings
and defines some properties of an OPC UA BrowseNext service invocation.Methods:
Attributes inherited from
pyuaf.client.settings.ServiceSettings
:-
ServiceSettings.
callTimeoutSec
¶ The maximum time allowed for each service communication between client and server, in seconds, as a
float
.
-
Additional attributes:
-
releaseContinuationPoints
¶ A
bool
indicating if the memory associated with the continuation point in the server should be released (True
) or not (False
).
-
class BrowseSettings¶
-
class
pyuaf.client.settings.
BrowseSettings
(*args)¶ A BrowseSettings is a subclass of
pyuaf.client.settings.ServiceSettings
and defines some properties of an OPC UA Browse service invocation.Methods:
Attributes inherited from
pyuaf.client.settings.ServiceSettings
:-
ServiceSettings.
callTimeoutSec
¶ The maximum time allowed for each service communication between client and server, in seconds, as a
float
.
-
Additional attributes:
-
maxReferencesToReturn
¶ An
int
: the maximum number of references to return. Default is 0, which means that the client is not imposing a limitation.
-
view
¶ Attribute of type
ViewDescription
that specifies the View to browse. Don’t touch if you want to browse the whole address space without restrictions.
-
maxAutoBrowseNext
¶ An
int
defined by the UAF, to indicate how many times the UAF may automatically call the BrowseNext service. Default = 0, which means that there will be no BrowseNext being called automatically. But if you put this value to e.g. 10, then you can very easily browse large address spaces since you don’t have to call BrowseNext manually every time (and there’s no risk of ending up in an endless loop since the UAF client will stop processing the request after 10 BrowseNext calls).
-
class ClientSettings¶
-
class
pyuaf.client.settings.
ClientSettings
(*args)¶ A ClientSettings object stores the settings of a
pyuaf.client.Client
.Usage example:
import pyuaf # create a default ClientSettings instance settings = pyuaf.client.settings.ClientSettings() # set the name and URI of the client settings.applicationName = "MyClient" settings.applicationUri = "/some/company/uri/myclient" # update the URLs to be used for the discovery of servers settings.discoveryUrls.append("opc.tcp://localhost:4841") settings.discoveryUrls.append("opc.tcp://10.33.178.81:4841") # alternative: alternativeSettings = pyuaf.client.settings.ClientSettings() alternativeSettings.discoveryUrls.resize(2) alternativeSettings.discoveryUrls[0] = "opc.tcp://localhost:4841" alternativeSettings.discoveryUrls[1] = "opc.tcp://10.33.178.81:4841"
Methods:
-
__init__
()¶ Construct a new ClientSettings object.
-
__str__
()¶ Get a formatted string representation of the settings.
-
createSecurityLocations
()¶ Create the security locations (directories).
These locations will be created (if they don’t exist already):
- certificateTrustListLocation
- certificateRevocationListLocation
- issuersCertificatesLocation
- issuersRevocationListLocation
- base path of clientPrivateKey
- base path of clientCertificate
Returns: A Good status if the locations were created (or if they already existed). A Bad status if some location could not be created (e.g. due to wrong permissions). Return type: Status
-
Attributes
Main attributes:
Attributes related to the logging
-
logToStdOutLevel
¶ When logging to the stdout, only log messages from at least this loglevel. The loglevels are of type
int
, as defined inpyuaf.util.loglevels
.
-
logToCallbackLevel
¶ When logging to the callback interface, only log messages from at least this loglevel. The loglevels are of type
int
, as defined inpyuaf.util.loglevels
.
-
Attributes related to the discovery process
-
discoveryUrls
¶ The list of URLs to be used by the client to discover servers (as a
StringVector
, which can be treated more or less as alist
ofstr
).
-
discoveryFindServersTimeoutSec
¶ The timeout value for the FindServers discovery service, in seconds, as a
float
.
-
discoveryGetEndpointsTimeoutSec
¶ The timeout value for the GetEndpoints discovery service, in seconds, as a
float
.
-
discoveryIntervalSec
¶ The interval between discovery attempts which are continuously running in the background, in seconds, as a
float
.
-
Attributes related to the network-wide discovery process (FindServersOnNetwork)
-
discoveryOnNetworkEnable
¶ If True, the FindServersOnNetwork service will be called automatically, on every discovery cycle. Default: False, type:
bool
.
-
discoveryFindServersTimeoutSec
The timeout value for the FindServersOnNetwork discovery service, in seconds, as a
float
.
-
discoveryOnNetworkDiscoveryServer
¶ The discovery server (as a
str
) to invoke the FindServersOnNetwork on. Default: “opc.tcp://localhost”.
-
discoveryOnNetworkStartingRecordId
¶ Only find servers with record id greater than this number. Default: 0, type:
int
.
-
discoveryOnNetworkServerCapabilities
¶ Only find servers with all of the given capabilities (as a
StringVector
, which can be treated more or less as alist
ofstr
). Default: empty vector, which means: no filter, find all.
-
discoveryOnNetworkStartingRecordId
Only find the given amount of servers on the network. Default: 0 (no limit), type:
int
.
-
Attributes related to security
-
certificateTrustListLocation
¶ The trust list location as a
str
.This directory can be specified either as an absolute path, or as a path relative to the application path.
Default: “PKI/trusted/certs/”.
-
certificateRevocationListLocation
¶ The revocation list location as a
str
.This directory can be specified either as an absolute path, or as a path relative to the application path.
Default: “PKI/trusted/crl/”.
-
issuersCertificatesLocation
¶ The issuers certificates location as a
str
.This directory can be specified either as an absolute path, or as a path relative to the application path.
Default: “PKI/issuers/certs/”.
-
issuersRevocationListLocation
¶ The issuers revocation list location as a
str
.This directory can be specified either as an absolute path, or as a path relative to the application path.
Default: “PKI/issuers/crl/”.
-
createSecurityLocationsIfNeeded
¶ A
bool
to automatically create the security-related directories if they don’t exist yet, or not.The following directories will be created if this boolean is
True
and if the UAF needs to connect to a secured endpoint and if these directories don’t exist already: - certificateTrustListLocation - certificateRevocationListLocation - issuersCertificatesLocation - issuersRevocationListLocationIf this boolean is
False
and the UAF needs to connect to a secured endpoint, the UAF will simply check if the above directories exist. If they don’t exist, the connection will fail and you’ll get an exception.Default: True
-
clientPrivateKey
¶ The private key of this client application as a
str
.This file can be specified either as an absolute path, or as a path relative to the application path.
Default: “PKI/client/private/client.pem”.
-
clientCertificate
¶ The certificate of this client application as a
str
.This file can be specified either as an absolute path, or as a path relative to the application path.
Default: “PKI/client/certs/client.der”.
-
Attributes related to default sessions and subscriptions
-
defaultSessionSettings
¶ These default settings will be used to create the sessions to servers, unless these servers have their URI mentioned in specificSessionSettings map (see next attribute). Type is
SessionSettings
.
-
specificSessionSettings
¶ A container that maps <server URIs> (of type
str
) to <session settings> (of typeSessionSettings
).When sessions need to be created to a server, the UAF will first check if the URI of this server is specified by this container. If so, then the corresponding “specific” session settings will be used. If not, then the
defaultSessionSettings
: will be used. This attribute is aSpecificSessionSettings
instance.
-
defaultSubscriptionSettings
¶ These default settings will be used to create the subscriptions Type is
SubscriptionSettings
.
-
Attributes related to default service settings
-
defaultBrowseNextSettings
¶ The default service settings to be used by
browseNext()
. Type isBrowseNextSettings
.
-
defaultBrowseSettings
¶ The default service settings to be used by
browse()
. Type isBrowseSettings
.
-
defaultCreateMonitoredDataSettings
¶ The default service settings to be used by
createMonitoredData()
. Type isCreateMonitoredDataSettings
.
-
defaultCreateMonitoredEventsSettings
¶ The default service settings to be used by
createMonitoredEvents()
. Type isCreateMonitoredEventsSettings
.
-
defaultCreateMonitoredEventsSettings
The default service settings to be used by
historyReadRaw()
andhistoryReadModified()
. Type isHistoryReadRawModifiedSettings
.
-
defaultMethodCallSettings
¶ The default service settings to be used by
call()
andbeginCall()
. Type isMethodCallSettings
.
-
defaultReadSettings
¶ The default service settings to be used by
read()
andbeginRead()
. Type isReadSettings
.
-
defaultTranslateBrowsePathsToNodeIdsSettings
¶ The default service settings to be used by
TranslateBrowsePathsToNodeIdsRequest
and most other services for translating the browsepaths of their targets. Type isTranslateBrowsePathsToNodeIdsSettings
.
-
defaultWriteSettings
¶ The default service settings to be used by
write()
andbeginWrite()
. Type isWriteSettings
.
-
defaultSetPublishingModeSettings
¶ The default service settings to be used by
setPublishingMode()
. Type isServiceSettings
.
-
defaultSetMonitoringModeSettings
¶ The default service settings to be used by
setMonitoringMode()
. Type isServiceSettings
.
-
class CreateMonitoredDataSettings¶
-
class
pyuaf.client.settings.
CreateMonitoredDataSettings
(*args)¶ A CreateMonitoredDataSettings is a subclass of
pyuaf.client.settings.ServiceSettings
and defines some properties of an OPC UA CreateMonitoredItems service invocation for data changes.Methods:
Attributes inherited from
pyuaf.client.settings.ServiceSettings
:-
ServiceSettings.
callTimeoutSec
¶ The maximum time allowed for each service communication between client and server, in seconds, as a
float
.
-
class CreateMonitoredEventsSettings¶
-
class
pyuaf.client.settings.
CreateMonitoredEventsSettings
(*args)¶ A CreateMonitoredEventsSettings is a subclass of
pyuaf.client.settings.ServiceSettings
and defines some properties of an OPC UA CreateMonitoredItems service invocation for events.Methods:
Attributes inherited from
pyuaf.client.settings.ServiceSettings
:-
ServiceSettings.
callTimeoutSec
¶ The maximum time allowed for each service communication between client and server, in seconds, as a
float
.
-
class HistoryReadRawModifiedSettings¶
-
class
pyuaf.client.settings.
HistoryReadRawModifiedSettings
(*args)¶ A HistoryReadRawModifiedSettings is a subclass of
pyuaf.client.settings.ServiceSettings
and defines some properties of an OPC UA HistoryReadRawModified service invocation.Methods:
Attributes inherited from
pyuaf.client.settings.ServiceSettings
:-
ServiceSettings.
callTimeoutSec
¶ The maximum time allowed for each service communication between client and server, in seconds, as a
float
.
-
Additional attributes:
-
startTime
¶ Begin of the time interval to read, as a
pyuaf.util.DateTime
instance.
-
endTime
¶ End of the time interval to read, as a
pyuaf.util.DateTime
instance.
-
isReadModified
¶ bool
flag: False if the values stored in the history database should be returned directly, True if the values that are replaced by other values (with the same timestamps) should be returned. Default is False.
-
maxAutoReadMore
¶ An
int
defined by the UAF, to indicate how many times the UAF may automatically call the history read OPC UA service additionally to the original request, in order to get more data. Default = 0, which means that there will be no extra service calls being invoked automatically. But if you put this value to e.g. 10, then you can very easily retrieve large amounts of historical data since you don’t have to call the service manually every time you get a non-NULL continuation point. You don’t need to use this attribute if you don’t want it (you can leave it at 0 to effectively disable it), but it can make your life easier!
-
numValuesPerNode
¶ An
int
specifying the maximum number of values that may be returned for each node. Default = 0 = no limit.
-
returnBounds
¶ bool
flag: True if the bounds (a value at or just before the start time and a value at or just after the end time) should be returned, False if not. Default is False.
-
timestampsToReturn
¶ Select and return the timestamps as specified by this
int
attribute (as defined in thepyuaf.util.timestampstoreturn
module). Ifpyuaf.util.timestampstoreturn.Both
is specified, the Source timestamp will be used for selection. Default ispyuaf.util.timestampstoreturn.Source
. Default = 0 = no limit.
-
releaseContinuationPoints
¶ bool
flag: True to let the Server know that no more historical data is needed, and so the server may release any resources associated with the call. Default is False.
-
class MethodCallSettings¶
-
class
pyuaf.client.settings.
MethodCallSettings
(*args)¶ A MethodCallSettings is a subclass of
pyuaf.client.settings.ServiceSettings
and defines some properties of an OPC UA MethodCall service invocation.Methods:
Attributes inherited from
pyuaf.client.settings.ServiceSettings
:-
ServiceSettings.
callTimeoutSec
¶ The maximum time allowed for each service communication between client and server, in seconds, as a
float
.
-
class MonitoredItemSettings¶
-
class
pyuaf.client.settings.
MonitoredItemSettings
(*args)¶ A MonitoredItemSettings object holds the properties of monitored items (both for monitoring data, and monitoring events).
Methods:
-
__init__
(*args)¶ Create a new MonitoredItemSettings object, by default for monitoring data.
Usage example:
import pyuaf from pyuaf.client.settings import MonitoredItemSettings # 1) create a default monitored item settings --> to monitor data changes # ----------------------------------------------------------------------- monIt = MonitoredItemSettings() # alternative: monIt = MonitoredItemSettings(MonitoredItemSettings.Data) monIt.samplingIntervalSec = 1.0 monIt.kind() # equals MonitoredItemSettings.Data monIt.dataChangeFilter.deadBandEnabled = True monIt.dataChangeFilter.deadBandValue = 1.0 # (monIt.eventFilter is None) # 2) create a monitored item settings to monitor events # ----------------------------------------------------------------------- monIt = MonitoredItemSettings(MonitoredItemSettings.Event) monIt.samplingIntervalSec = 1.0 monIt.kind() # equals MonitoredItemSettings.Event monIt.eventFilter.selectClauses.resize(3) # (monIt.dataChangeFilter is None)
-
kind
()¶ Get the kind of monitored item settings: is it to monitor data changes, or events?
Returns: Either pyuaf.client.settings.MonitoredItemSettings.Data
orpyuaf.client.settings.MonitoredItemSettings.Event
.Return type: int
-
__str__
()¶ Get a formatted string representation of the settings.
-
Class attributes:
Attributes:
-
samplingIntervalSec
¶ The sampling interval of the monitored item, in seconds, as a
float
.
-
queueSize
¶ The queue size on the server side, as an
int
.
-
discardOldest
¶ True to discard the oldest item in the queue.
Type of the attribute:
bool
.
-
dataChangeFilter
¶ The
DataChangeFilter
in case thekind()
ispyuaf.client.settings.MonitoredItemSettings.Data
.None
otherwise!
-
eventFilter
¶ The
EventFilter
in case thekind()
ispyuaf.client.settings.MonitoredItemSettings.Event
.None
otherwise!
-
class ReadSettings¶
-
class
pyuaf.client.settings.
ReadSettings
(*args)¶ A ReadSettings is a subclass of
pyuaf.client.settings.ServiceSettings
and defines some properties of an OPC UA Read service invocation.Methods:
Attributes inherited from
pyuaf.client.settings.ServiceSettings
:-
ServiceSettings.
callTimeoutSec
¶ The maximum time allowed for each service communication between client and server, in seconds, as a
float
.
-
Additional attributes:
-
maxAgeSec
¶ The maximum age (in seconds) that the attribute that is read, should have, as a
float
.
-
class SessionSettings¶
-
class
pyuaf.client.settings.
SessionSettings
(*args)¶ A SessionSettings object stores the settings of an OPC UA session.
Methods:
-
__init__
()¶ Construct a new SessionSettings object with the following default values:
- sessionTimeoutSec = 1200.0
- connectTimeoutSec = 2.0
- watchdogTimeoutSec = 2.0
- watchdogTimeSec = 5.0
- securitySettings = a default
SessionSecuritySettings
instance.
-
__str__
()¶ Get a formatted string representation of the settings.
-
Attributes
-
sessionTimeoutSec
¶ The time a session should remain valid on the server after a connection error, as a
float
.
-
connectTimeoutSec
¶ The timeout for the connect call, as a
float
.
-
watchdogTimeSec
¶ The time between watchdog calls, as a
float
.
-
watchdogTimeoutSec
¶ The timeout of watchdog calls, as a
float
.
-
readServerInfoSettings
¶ The settings to be used to read the namespace array and server array, when the session is first connected (UAF clients will do this automatically in the background). The type of this attribute is
ReadSettings
.
-
securitySettings
¶ The security settings to be used to connect the session.
The type of this attribute is
SessionSecuritySettings
.
-
unique
¶ Set this flag to True, to force the UAF to create a new session. If you leave this flag False, the UAF may choose to re-use an existing session (if one is found that has the same properties).
The type of this attribute is
bool
.
-
class SessionSecuritySettings¶
-
class
pyuaf.client.settings.
SessionSecuritySettings
(*args)¶ A SessionSecuritySettings object stores the security settings of an OPC UA session.
Methods:
-
__init__
()¶ Create a default SessionSecuritySettings object.
- A default instance has
- no security policy (
pyuaf.util.securitypolicies.UA_None
) - no security mode (
pyuaf.util.messagesecuritymodes.Mode_None
) - no authentication (
pyuaf.util.usertokentypes.Anonymous
)
- no security policy (
-
__str__
()¶ Get a formatted string representation of the settings.
-
Attributes
-
securityPolicy
¶ The security policy to be used (e.g.
pyuaf.util.securitypolicies.UA_Basic128
), as astr
.
-
messageSecurityMode
¶ The message security mode to be used (e.g.
pyuaf.util.messagesecuritymodes.Mode_SignAndEncrypt
), as anint
.
-
userTokenType
¶ The type of the User token, to be used (e.g.
pyuaf.util.usertokentypes.Anonymous
), as anint
.
-
userName
¶ The user name, as a
str
(only relevant if theuserTokenType
==pyuaf.util.usertokentypes.UserName
).
-
userPassword
¶ The user password, as a
str
(only relevant if theuserTokenType
==pyuaf.util.usertokentypes.UserName
).
-
userCertificateFileName
¶ The user certificate file name, as a
str
(only relevant if theuserTokenType
==pyuaf.util.usertokentypes.Certificate
).
-
userPrivateKeyFileName
¶ The user certificate private key file name, as a
str
(only relevant if theuserTokenType
==pyuaf.util.usertokentypes.Certificate
).
-
class SessionSecuritySettingsVector¶
-
class
pyuaf.client.settings.
SessionSecuritySettingsVector
¶ A SessionSecuritySettingsVector is a container that holds elements of type
SessionSecuritySettings
. It is an artifact automatically generated from the C++ UAF code, and has the same functionality as alist
ofpyuaf.client.settings.SessionSecuritySettings
.Usage example:
import pyuaf from pyuaf.client.settings import SessionSecuritySettings, SessionSecuritySettingsVector # construct a SessionSecuritySettingsVector without elements: vec = SessionSecuritySettingsVector() noOfElements = len(vec) # will be 0 vec.append(SessionSecuritySettings()) vec[0].securityPolicy = pyuaf.util.securitypolicies.UA_Basic128 vec[0].messageSecurityMode = pyuaf.util.messagesecuritymodes.Mode_SignAndEncrypt vec[0].userTokenType = pyuaf.util.usertokentypes.UserName vec[0].userName = "John" noOfElements = len(vec) # will be 1 vec.resize(4) noOfElements = len(vec) # will be 4 # you may construct an ApplicationDescriptionVector from a regular Python list: # - create a first SessionSecuritySettings object settings0 = SessionSecuritySettings() settings0.securityPolicy = pyuaf.util.securitypolicies.UA_None # - create a second SessionSecuritySettings object settings1 = SessionSecuritySettings() settings1.securityPolicy = pyuaf.util.securitypolicies.UA_Basic128 settings1.messageSecurityMode = pyuaf.util.messagesecuritymodes.Mode_SignAndEncrypt settings1.userTokenType = pyuaf.util.usertokentypes.UserName settings1.userName = "John" # - create the vector otherVec = SessionSecuritySettingsVector( [settings0, settings1] )
class SpecificSessionSettings¶
-
class
pyuaf.client.settings.
SpecificSessionSettings
(*args)¶ SpecificSessionSettings is a container that maps serverURIs (of type
str
) to session settings (of typeSessionSettings
).It is an artifact automatically generated from the C++ UAF code, and has the same functionality as a
dict
ofSessionSettings
.Usage example:
import pyuaf from pyuaf.client.settings import SessionSettings, SpecificSessionSettings # construct an empty SpecificSessionSettings map: specifics = SpecificSessionSettings() noOfPairs = len(vec) # will be 0 # add some specific session settings for a server with URI "/some/URI/" specifics["/some/URI/"] = SessionSettings() specifics["/some/URI/"].sessionTimeoutSec = 600.0 specifics["/some/URI/"].connectTimeoutSec = 2.0 noOfPairs = len(vec) # will be 1 # add some other specific session settings for a server with URI "/some/other/URI/" specifics["/some/other/URI/"] = SessionSettings() specifics["/some/other/URI/"].sessionTimeoutSec = 800.0 specifics["/some/other/URI/"].connectTimeoutSec = 3.0 noOfPairs = len(vec) # will be 2 # now remove the first entry specifics.erase("/some/other/URI/") # get the keys, the values, the items keys = specifics.keys() values = specifics.values() items = specifics.items() # clear the whole map specifics.clear() # check if a key is present specifics.has_key("/some/other/URI/") # ...
class SubscriptionSettings¶
-
class
pyuaf.client.settings.
SubscriptionSettings
(*args)¶ A SubscriptionSettings object stores the settings of an OPC UA subscription.
Methods:
Attributes
-
unique
¶ Set this flag to True, to force the UAF to create a new subscription. If you leave this flag False, the UAF may choose to re-use an existing subscription (if one is found that has the same properties).
The type of this attribute is
bool
.
-
publishingIntervalSec
¶ The publishing interval in seconds, as a
float
.
-
lifeTimeCount
¶ The life time count, as an
int
.
-
maxKeepAliveCount
¶ The max keep alive count, as an
int
.
-
maxNotificationsPerPublish
¶ The max number of notifications per publish, as an
int
.
-
priority
¶ The priority of the subscription, as an
int
. Since this value is only 8-bit, the maximum priority is 255.
-
class TranslateBrowsePathsToNodeIdsSettings¶
-
class
pyuaf.client.settings.
TranslateBrowsePathsToNodeIdsSettings
(*args)¶ A TranslateBrowsePathsToNodeIdsSettings is a subclass of
pyuaf.client.settings.ServiceSettings
and defines some properties of an OPC UA TranslateBrowsePathsToNodeIds service invocation.Methods:
Attributes inherited from
pyuaf.client.settings.ServiceSettings
:-
ServiceSettings.
callTimeoutSec
¶ The maximum time allowed for each service communication between client and server, in seconds, as a
float
.
-
class WriteSettings¶
-
class
pyuaf.client.settings.
WriteSettings
(*args)¶ A WriteSettings is a subclass of
pyuaf.client.settings.ServiceSettings
and defines some properties of an OPC UA Write service invocation.Methods:
Attributes inherited from
pyuaf.client.settings.ServiceSettings
:-
ServiceSettings.
callTimeoutSec
¶ The maximum time allowed for each service communication between client and server, in seconds, as a
float
.
-