High level Server class This class creates an opcua server with default values Create your own namespace and then populate your server address space using use the get_root() or get_objects() to get Node objects. and get_event_object() to fire events. Then start server. See
| 35 | |
| 36 | |
| 37 | class Server(object): |
| 38 | |
| 39 | """ |
| 40 | High level Server class |
| 41 | |
| 42 | This class creates an opcua server with default values |
| 43 | |
| 44 | Create your own namespace and then populate your server address space |
| 45 | using use the get_root() or get_objects() to get Node objects. |
| 46 | and get_event_object() to fire events. |
| 47 | Then start server. See example_server.py |
| 48 | All methods are threadsafe |
| 49 | |
| 50 | If you need more flexibility you call directly the Ua Service methods |
| 51 | on the iserver or iserver.isession object members. |
| 52 | |
| 53 | During startup the standard address space will be constructed, which may be |
| 54 | time-consuming when running a server on a less powerful device (e.g. a |
| 55 | Raspberry Pi). In order to improve startup performance, a optional path to a |
| 56 | cache file can be passed to the server constructor. |
| 57 | If the parameter is defined, the address space will be loaded from the |
| 58 | cache file or the file will be created if it does not exist yet. |
| 59 | As a result the first startup will be even slower due to the cache file |
| 60 | generation but all further start ups will be significantly faster. |
| 61 | |
| 62 | :ivar product_uri: |
| 63 | :vartype product_uri: uri |
| 64 | :ivar name: |
| 65 | :vartype name: string |
| 66 | :ivar default_timeout: timeout in milliseconds for sessions and secure channel |
| 67 | :vartype default_timeout: int |
| 68 | :ivar iserver: internal server object |
| 69 | :vartype default_timeout: InternalServer |
| 70 | :ivar bserver: binary protocol server |
| 71 | :vartype bserver: BinaryServer |
| 72 | :ivar nodes: shortcuts to common nodes |
| 73 | :vartype nodes: Shortcuts |
| 74 | |
| 75 | """ |
| 76 | |
| 77 | if use_crypto is False: |
| 78 | logging.getLogger(__name__).warning("cryptography is not installed, use of crypto disabled") |
| 79 | |
| 80 | def __init__(self, shelffile=None, iserver=None): |
| 81 | self.logger = logging.getLogger(__name__) |
| 82 | self.endpoint = urlparse("opc.tcp://0.0.0.0:4840/freeopcua/server/") |
| 83 | self._application_uri = "urn:freeopcua:python:server" |
| 84 | self.product_uri = "urn:freeopcua.github.io:python:server" |
| 85 | self.name = "FreeOpcUa Python Server" |
| 86 | self.manufacturer_name = "FreeOpcUa" |
| 87 | self.application_type = ua.ApplicationType.ClientAndServer |
| 88 | self.default_timeout = 3600000 |
| 89 | if iserver is not None: |
| 90 | self.iserver = iserver |
| 91 | else: |
| 92 | self.iserver = InternalServer(shelffile = shelffile) |
| 93 | self.bserver = None |
| 94 | self._policies = [] |
no outgoing calls