cut 3.3.0
Loading...
Searching...
No Matches
comms.oldbadapter.OldbAdapter Class Reference

Python wrapper for OLDB client, uses Singleton pattern. More...

Public Member Functions

 __new__ (cls)
 Method that indicates how a new object for this class is created.
 
 use_in_memory (self)
 Intended for tending, this method prepares an in-memory OLDB.
 
bool connect (self, CiiOldbConfigClass configuration=None, int timeout=5)
 Connects to OLDB.
 
 disconnect (self)
 Disconnects from OLDB.
 
 connect_async (self, CiiOldbConfigClass configuration=None, int timeout=5)
 Single connection attempt in a separate thread.
 
 start_connect_cycle (self, CiiOldbConfigClass configuration=None)
 Starts a cycle of connection/pings until stopped.
 
CiiOldb get_client (self)
 Returns the OLDB client object reference.
 
bool ping (self)
 Executes short query on OLDB to check if connected is still available.
 

Protected Member Functions

 _connect_cycle (self, CiiOldbConfigClass configuration=None)
 Starts a Connection cycle.
 

Detailed Description

Python wrapper for OLDB client, uses Singleton pattern.

This class facilitates connection to OLDB. Configures timeouts, concentrates retries to connect, checks for status of connection, among other things.

This class does not use QObject, as it is intended to be used in a taurus plugin.

Notes
  • Once an OLDB client is gotten, it should always return the same object. If a disconnection is detected, then this is informed. The CiiOldb object has to keep subscriptions, so we cannot delete it and get a new one. Also, the Oldb library should always give us the same refence (IMO).
  • This class is pure python (QeOldbAdapter is a QObject and offers signal/slots/properties)
  • There should be a synchronous and an asynchronous connection method.
  • If the asynchronous method is used the developer should add a listener object. From then on, the OldbAdapter will inform of connection changes the listener object.
  • Listener refs are weak references. To avoid introducing a counter increment for GC.

Member Function Documentation

◆ __new__()

comms.oldbadapter.OldbAdapter.__new__ ( cls)

Method that indicates how a new object for this class is created.

Implements singleton pattern. The first object created will store a "static" reference of the same object, and from then on the "static" reference is returned.

◆ _connect_cycle()

comms.oldbadapter.OldbAdapter._connect_cycle ( self,
CiiOldbConfigClass configuration = None )
protected

Starts a Connection cycle.

Do not use this method in a synchronous manner, otherwise it will block without finishing.

This method enter a neverending cycle. It will try to:

  • keep connecting to OLDB.
  • when connected, it will keep pinging.
  • if disconnection is detected, will try to reconnect

◆ connect()

bool comms.oldbadapter.OldbAdapter.connect ( self,
CiiOldbConfigClass configuration = None,
int timeout = 5 )

Connects to OLDB.

If connection fails, every other attempt will be reported as failed during the window.

The whole method is protected by a mutex. So at any point in time, only one connection attempt can happen. If a second attempt is requested, the mutex will make sure they are "queued".

Also fires a Connection event to the listeners.

Parameters
[in]configurationAllows to inject a particular CiiOldbConfigClass
Todo
Add elt.oldb.CiiOldbTimeoutException handling on CIISRV4 see https://jira.eso.org/browse/ECII-689

◆ connect_async()

comms.oldbadapter.OldbAdapter.connect_async ( self,
CiiOldbConfigClass configuration = None,
int timeout = 5 )

Single connection attempt in a separate thread.

Developer should connect a listener before invoking this method.

◆ disconnect()

comms.oldbadapter.OldbAdapter.disconnect ( self)

Disconnects from OLDB.

Also fires a Connection event to the listeners.

@TODO: Implement close

◆ get_client()

CiiOldb comms.oldbadapter.OldbAdapter.get_client ( self)

Returns the OLDB client object reference.

If the reference is None, the developer needs to request connection first.

◆ ping()

bool comms.oldbadapter.OldbAdapter.ping ( self)

Executes short query on OLDB to check if connected is still available.

Returns
True when ping is succesfull, False when it is not
Todo
measure roundtrip and return that instead or None

◆ start_connect_cycle()

comms.oldbadapter.OldbAdapter.start_connect_cycle ( self,
CiiOldbConfigClass configuration = None )

Starts a cycle of connection/pings until stopped.

Every second, the cycle will try to connect to the OLDB, with a timeout of 1 second. If succesfull, it will use the ping() method, which will update the connection status automatically. If disconnection is detected, will start connections attempts.

All connection changes are notified to listeners.

Only one connection cycle can be running. Additional requests will be logged and return immediately.


The documentation for this class was generated from the following file: