sdurw_common module

class sdurw_common.sdurw_common.Archive(*args, **kwargs)

Bases: object

archive interface for serializaion classes.

__init__(*args, **kwargs)
close()

close the archive.

flush()

flush the archive. Anything stored in buffers will be flushed to the actual media that has been openned.

isOpen()

test if this archive is openned for manipulation. If this is false then no storage will be performed. :rtype: boolean :return: true if Archive is ready for streaming

open(*args)

Overload 1:

open file for reading and writing :type filename: string :param filename:


Overload 2:

initialize archive for reading and/or writing to a stream :type stream: std::iostream :param stream: [in] the stream


Overload 3:

open an output stream for writing


Overload 4:

open an inputstream for reading

property thisown

The membership flag

class sdurw_common.sdurw_common.BINArchive(*args)

Bases: InputArchive, OutputArchive

archive for loading and saving serializable classes.

__init__(*args)
Overload 1:

constructor


Overload 2:

Constructor. :type ofs: std::ostream :param ofs: [out] output stream to write to.

close()

close streaming to archive

flush()

flush the archive. Anything stored in buffers will be flushed to the actual media that has been openned.

isOpen()

test if this archive is openned for manipulation. If this is false then no storage will be performed. :rtype: boolean :return: true if Archive is ready for streaming

property thisown

The membership flag

class sdurw_common.sdurw_common.INIArchive(*args)

Bases: InputArchive, OutputArchive

archive for loading and saving serializable classes to an ini-file format.

__init__(*args)
close()

close this archive for streaming

flush()

flush the archive. Anything stored in buffers will be flushed to the actual media that has been openned.

isOpen()

test if this archive is openned for manipulation. If this is false then no storage will be performed. :rtype: boolean :return: true if Archive is ready for streaming

property thisown

The membership flag

class sdurw_common.sdurw_common.InputArchive(*args, **kwargs)

Bases: Archive

an archive interface for reading from a serialized class.

__init__(*args, **kwargs)
readBool(id)

read boolean

readDouble(id)

read double floating point

readEnterScope(*args)

enter specific scope with id when reading. :type id: string :param id: [in] id of the scope to enter :type idDefault: string, optional :param idDefault: [in] the default scope id

readInt(id)

read integer

readInt64(id)

read 64 bit integer

readInt8(id)

read 8 bit integer

readLeaveScope(*args)

leave specific scope with id when reading. :type id: string :param id: [in] id of the scope to leave :type idDefault: string, optional :param idDefault: [in] the default scope id

readString(id)

read string

readUInt(id)

read unsigned integer

readUInt64(id)

read 64 bit unsigned integer

readUInt8(id)

read 8 bit unsigned integer

property thisown

The membership flag

class sdurw_common.sdurw_common.LogBufferedChar(*args)

Bases: LogWriter

Buffers characters before writing them to the output stream.

The size of the buffer is fixed. On overflow the behavior depends on the specified OverFlowPolicy. If a single message is larger than the entire content of the buffer it is truncated.

AUTO_FLUSH = 2

Automatically calls flush to write the buffer and the new message to the output stream. Using AUTO_FLUSH it is possible to write messages larger than the buffer size.

REMOVE_FIRST = 0

Remove the first added content (circular queue)

REMOVE_LAST = 1

Skip the content which does not fit input the buffer

__init__(*args)

Constructs a LogBufferedChar

The LogBufferedMsg keeps a reference to the stream object. Destroying the stream object while the LogBufferedChar has a reference to it results in undefined behavior.

Parameters
  • size (int) – [in] Size of buffer (in characters)

  • stream (std::ostream) – [in] Stream to write to

  • policy (int, optional) – [in] Overflow policy. Default is REMOVE_FIRST

property thisown

The membership flag

class sdurw_common.sdurw_common.LogBufferedMsg(stream)

Bases: LogWriter

Buffers messages before writing them to the output stream.

The size of the buffer is not fixed and will grow until flush is called. To have a fixed size buffer use LogBufferedChar instead.

__init__(stream)

Constructs LogBufferedMsg with a target ostream

The LogBufferedMsg keeps a reference to the stream object. Destroying the stream object while the LogBufferedMsg has a reference to it results in undefined behavior.

Parameters

stream (std::ostream) – [in] Stream to write to

property thisown

The membership flag

class sdurw_common.sdurw_common.LogFileWriter(filename)

Bases: LogWriter

Writes log output to a file

__init__(filename)

Constructs LogFileWriter writing to a file named filename

Throws exception if failing to open file

Parameters

filename (string) – [in] Name of file

property thisown

The membership flag

class sdurw_common.sdurw_common.LogMultiWriter

Bases: LogWriter

Writes log output to multiple LogWriters

__init__()

Constructs empty LogMultiWriter

addWriter(writer)

Adds a LogWriter to be written to

property thisown

The membership flag

class sdurw_common.sdurw_common.OutputArchive(*args, **kwargs)

Bases: Archive

serializable objects can be written to an output archive.

This class define an interface for serializing data.

__init__(*args, **kwargs)
property thisown

The membership flag

writeEnterScope(*args)

create a serialized scope in which objects can be written :type id: string :param id: [in] id of the scope :type idDefault: string, optional :param idDefault: [in] (optional) default id to use if id is an empty string.

writeLeaveScope(*args)

leave the current scope :type id: string :param id: [in] id of the scope :type idDefault: string, optional :param idDefault: [in] (optional) default id to use if id is an empty string.

class sdurw_common.sdurw_common.ProgramOptions(applicationName, version)

Bases: object

a class for parsing program command line into a PropertyMap

__init__(applicationName, version)

Construct new set of program options. :type applicationName: string :param applicationName: [in] the name of the application. :type version: string :param version: [in] the version of the application.

addBoolOption(name, defval, desc)

add a bool option that is only allowed to occur once on the command line :type name: string :param name: [in] name of option :type defval: boolean :param defval: [in] the default value when arg not present :type desc: string :param desc: [in] description of commandline option

addStringOption(name, defval, desc)

add a string option that is only allowed to occur once on the command line :type name: string :param name: [in] name of option :type defval: string :param defval: [in] the default string value if any :type desc: string :param desc: [in] description of commandline option

getOptionDescription()

Get the underlying program options description from boost. :rtype: boost::program_options::options_description :return: reference to options_description.

getPosOptionDescription()

Get the underlying positional program options description from boost. :rtype: boost::program_options::positional_options_description :return: reference to positional_options_description.

getPropertyMap()

Get parsed properties in RobWork format in the form of a PropertyMap. :rtype: PropertyMap :return: the property map with parsed options.

initOptions()

this initialize default options that can add simple properties to the propertymap.

parse(*args)

Overload 1:

parses input, if :type argc: int :param argc: :type argv: string :param argv: :rtype: int :return: if 0 is returned then help or an error


Overload 2:

Parses input from a string. :type string: string :param string: [in] input line. :rtype: int :return: 0 if success.

setPositionalOption(name, i)

Set name of option number i. :type name: string :param name: [in] the name. :type i: int :param i: [in] index of the option.

property thisown

The membership flag

class sdurw_common.sdurw_common.ScopedTimer(timer)

Bases: object

Times what is executed in a scope.

Automatically calls resume on the timer given in construction and pause when destroyed.

Notes: usage

...
long time;
{
  // put code here that is not to be timed
  ScopedTimer timer(time);
  // put code here that is to be timed
}
std::cout << "Time: " << time << std::endl;
__init__(timer)

constructor. Starts the timer :type timer: Timer :param timer:

getTimer()

Returns the time wrapped in the ScopedTimer :rtype: Timer :return: Timer wrapped

property thisown

The membership flag

class sdurw_common.sdurw_common.Serializable(*args, **kwargs)

Bases: object

interface for defining serialization of classes. If a class cannot inherit the Serializable because of non-access to code then one can instead provide overloaded read/write methods to perform the serialization.

__init__(*args, **kwargs)
read(iarchive, id)

Enable read-serialization of inherited class by implementing this method. Data is read from iarchive and filled into this object. :type iarchive: InputArchive :param iarchive: [in] the InputArchive from which to read data. :type id: string :param id: [in] The id of the serialized sobject.

Notes: the id can be empty in which case the overloaded method should provide a default identifier. E.g. the Vector3D class defined “Vector3D” as its default id.

property thisown

The membership flag

write(oarchive, id)

Enable write-serialization of inherited class by implementing this method. Data is written to oarchive from this object. :type oarchive: OutputArchive :param oarchive: [out] the OutputArchive in which data should be written. :type id: string :param id: [in] The id of the serialized sobject.

Notes: the id can be empty in which case the overloaded method should provide a default identifier. E.g. the Vector3D class defined “Vector3D” as its default id.

class sdurw_common.sdurw_common.ThreadPool(threads=-1)

Bases: object

A thread pool that can be assigned work.

Work is handled in a FIFO manner, and the pool is intended to be very simple and basic.

For more complex behaviour please look at the ThreadTask type, which has a higher abstraction for adding tasks to a ThreadPool.

__init__(threads=-1)

Create new thread pool using the given number of threads.

If no argument is given, the maximum number of hardware threads on the system is used (number of CPUs, cores or hyperthreading units).

If number of threads is set to 0, the addWork function will be blocking (work is executed in thread that invokes addWork).

Parameters

threads (int, optional) – number of threads to use - default is the number of hardware threads available on the system.

addWork(work)

Add work to the thread pool.

getNumberOfThreads()

Get number of threads in the pool.

getQueueSize()

Get the number of current tasks in the queue (tasks are removed from queue when done). :rtype: int :return: the number of current tasks.

isStopping()

Check if work tasks are supposed to shut itself down.

This function should be called from long-running worker functions to let them shut down gracefully.

Return type

boolean

Returns

true if thread should shut down.

stop()

Stop processing more work in the queue, and try to stop running work if possible.

Long-running work should check if the isStopping function returns true and shut down gracefully.

Interrupts are issued, so if there is interruption points in the WorkFunction, the work should check for boost::thread_interrupted exceptions and shut down gracefully.

property thisown

The membership flag

waitForEmptyQueue()

Wait until the task queue becomes empty.

class sdurw_common.sdurw_common.ThreadPoolCPtr(*args)

Bases: object

Ptr stores a pointer and optionally takes ownership of the value.

__init__(*args)

Overload 1:

Default constructor yielding a NULL-pointer.


Overload 2:

Do not take ownership of ptr.

ptr can be null.

The constructor is implicit on purpose.

deref()

The pointer stored in the object.

getDeref()

Member access operator.

getNumberOfThreads()

Get number of threads in the pool.

isNull()

checks if the pointer is null :rtype: boolean :return: Returns true if the pointer is null

isShared()

check if this Ptr has shared ownership or none ownership :rtype: boolean :return: true if Ptr has shared ownership, false if it has no ownership.

property thisown

The membership flag

class sdurw_common.sdurw_common.ThreadPoolPtr(*args)

Bases: object

Ptr stores a pointer and optionally takes ownership of the value.

__init__(*args)

Overload 1:

Default constructor yielding a NULL-pointer.


Overload 2:

Do not take ownership of ptr.

ptr can be null.

The constructor is implicit on purpose.

addWork(work)

Add work to the thread pool.

cptr()
deref()

The pointer stored in the object.

getDeref()

Member access operator.

getNumberOfThreads()

Get number of threads in the pool.

getQueueSize()

Get the number of current tasks in the queue (tasks are removed from queue when done). :rtype: int :return: the number of current tasks.

isNull()

checks if the pointer is null :rtype: boolean :return: Returns true if the pointer is null

isShared()

check if this Ptr has shared ownership or none ownership :rtype: boolean :return: true if Ptr has shared ownership, false if it has no ownership.

isStopping()

Check if work tasks are supposed to shut itself down.

This function should be called from long-running worker functions to let them shut down gracefully.

Return type

boolean

Returns

true if thread should shut down.

stop()

Stop processing more work in the queue, and try to stop running work if possible.

Long-running work should check if the isStopping function returns true and shut down gracefully.

Interrupts are issued, so if there is interruption points in the WorkFunction, the work should check for boost::thread_interrupted exceptions and shut down gracefully.

property thisown

The membership flag

waitForEmptyQueue()

Wait until the task queue becomes empty.

class sdurw_common.sdurw_common.ThreadTask(*args)

Bases: object

A task that facilitates the use of a hierarchic tree of tasks and subtasks.

Often parallel processing can be done at multiple levels. Typically it is not known beforehand if some task can be split into multiple smaller subtasks or not. The ThreadTask keeps track of the state of all its subtasks - only when all subtasks have been processed, the parent task will be able to finish. Instead of finishing, it can also choose to add new subtasks that depends on the result of the previously run subtasks.

The ThreadTask can utilize a ThreadPool of arbitrary size (down to 0 threads). When 0 threads are used, the addSubTask() function will be blocking and execute the work immediately. If more than 0 threads are used, the addSubTask function will return immediately, and the task is instead added to the work queue for processing when a thread becomes available.

There are two ways to use the ThreadTask:

  • Use it as a grouping mechanism: here one or more subtasks can be added for parallel

processing. One can use the ThreadPool size to adjust the number of threads one wants to use for a specific application.

  • Subclass it and override the four standard functions to make more complex

“branch-and-combine-results” type of tasks.

The four standard functions are as follows:

run() is the main work unit of the ThreadTask.

subTaskDone() is called each time a subtask has ended.

idle() is called when the task has finished its run() function and all subtasks has ended.

done() is the final function called before the ThreadTask is ended completely.

Please remember that the four functions can in general not be expected to be run in the same thread! In the first three functions it is allowed to add new subtasks to keep the thread running. In the done() function this is not allowed (it is simply ignored as the task will end immediately after this function has been called).

CHILDREN = 3

The run loop has finished, but children are still running.

DONE = 6

The done function has been invoked, and the task is now completed and dead.

EXECUTING = 2

The run function of the task is executing in the pool.

IDLE = 4

The idle function is called and subtasks can still be added. If the keep alive has been enabled, the task will stay in this state and not continue to the POSTWORK state.

INITIALIZATION = 0

Before execute has been called the first time.

IN_QUEUE = 1

Task has added its work to the pool, waiting for thread to become available.

POSTWORK = 5

The task does not accept any more new subtasks - the done function is invoked.

__init__(*args)

Overload 1:

Create task that will inherit parents thread pool.

Parameters

parent (Ptr) – [in] the parent task to take the thread pool from.


Overload 2:

Create task that will use a specific thread pool. If no thread pool is given, the task will not use parallelization. :type pool: rw::core::Ptr< rw::common::ThreadPool >, optional :param pool: [in] (optional) a pointer to the ThreadPool to use.


Overload 3:

Create task that will use a specific thread pool. If no thread pool is given, the task will not use parallelization. :param pool: [in] (optional) a pointer to the ThreadPool to use.

addSubTask(subtask)

Add a child task to this task.

This task will not end before all child tasks has ended. Never call execute on the child tasks - they will be executed by the parent task.

Parameters

subtask (Ptr) – the ThreadTask to add as child.

Return type

boolean

Returns

true if child was added successfully (only if task has not already ended)

done()

Function is executed when work is finished (at this point new subtasks can NOT be added).

execute()

Start executing the work in this task and all subtasks already added, by using the assigned ThreadPool. Notes: There is no guarantee that the parent run() function starts executing before the childrens run() functions. :rtype: boolean :return: true if execution started successfully, false if already running or thread has

finished.

getException()

Get a list of exceptions registered in task and subtasks. :rtype: std::vector< rw::core::Exception > :return: a list of exceptions.

getState()

Get the current state of the task (non-blocking). :rtype: int :return: the current TaskState.

getSubTasks()

Get the subtasks currently added to the ThreadTask. :rtype: std::vector< rw::common::ThreadTask::Ptr > :return: a vector of subtasks.

getThreadPool()

Get the ThreadPool that is used by this task currently.

Return type

rw::core::Ptr< rw::common::ThreadPool >

Returns

pointer to the ThreadPool.

idle()

Function is executed when the task becomes idle (new subtasks can be added in this function).

keepAlive()

Check is the task has keep alive option enabled. :rtype: boolean :return: true if task should be kept alive, false otherwise.

registerFailure(asNumpy)

Mark the task as a failure by registering an exception.

The user should override the #subTaskDone function in the parent task to either handle the exceptions appropriately or propagate them further on.

Parameters

e (Exception) – [in] an exception describing the problem.

run()

Function is the first function executed to do the actual work (new subtasks can

be added in this function).

setKeepAlive(enable)

Choose if the thread should exit automatically when all work and children has finished (this is the default).

Remember to set this to false when there is no more work to be done by the task, to allow the task to stop.

Parameters

enable (boolean) – [in] true if the thread should NOT finish automatically.

setThreadPool(pool)

Set which ThreadPool to use to do the actual execution of work. When execution is started the pool can not be changed anymore. :type pool: rw::core::Ptr< rw::common::ThreadPool > :param pool: [in] pointer to the pool :rtype: boolean :return: true if change was successful, false otherwise.

subTaskDone(subtask)
Function is executed each time a subtask has finished (new subtasks can be added

in this function). If #registerFailure is used to register failures in subtasks, this

function should handle or propagate the failures. The default implementation of this function is as follows:

for(const Exception& esubtask->getExceptions()) {

registerFailure(e);

}

Parameters

subtask (ThreadTask) – [in] the subtask that just finished.

property thisown

The membership flag

wait(previous)

Wait until state of task changes (blocking).

Remember to check if the new State is the desired (for instance DONE).

Parameters

previous (int) – [in] the previous state (wait for changes from this)

Return type

int

Returns

the new TaskState

waitUntilDone()

Wait until state of task changes to DONE (blocking).

class sdurw_common.sdurw_common.ThreadTaskCPtr(*args)

Bases: object

Ptr stores a pointer and optionally takes ownership of the value.

__init__(*args)

Overload 1:

Default constructor yielding a NULL-pointer.


Overload 2:

Do not take ownership of ptr.

ptr can be null.

The constructor is implicit on purpose.

deref()

The pointer stored in the object.

getDeref()

Member access operator.

isNull()

checks if the pointer is null :rtype: boolean :return: Returns true if the pointer is null

isShared()

check if this Ptr has shared ownership or none ownership :rtype: boolean :return: true if Ptr has shared ownership, false if it has no ownership.

property thisown

The membership flag

class sdurw_common.sdurw_common.ThreadTaskPtr(*args)

Bases: object

Ptr stores a pointer and optionally takes ownership of the value.

__init__(*args)

Overload 1:

Default constructor yielding a NULL-pointer.


Overload 2:

Do not take ownership of ptr.

ptr can be null.

The constructor is implicit on purpose.

addSubTask(subtask)

Add a child task to this task.

This task will not end before all child tasks has ended. Never call execute on the child tasks - they will be executed by the parent task.

Parameters

subtask (Ptr) – the ThreadTask to add as child.

Return type

boolean

Returns

true if child was added successfully (only if task has not already ended)

cptr()
deref()

The pointer stored in the object.

done()

Function is executed when work is finished (at this point new subtasks can NOT be added).

execute()

Start executing the work in this task and all subtasks already added, by using the assigned ThreadPool. Notes: There is no guarantee that the parent run() function starts executing before the childrens run() functions. :rtype: boolean :return: true if execution started successfully, false if already running or thread has

finished.

getDeref()

Member access operator.

getException()

Get a list of exceptions registered in task and subtasks. :rtype: std::vector< rw::core::Exception > :return: a list of exceptions.

getState()

Get the current state of the task (non-blocking). :rtype: int :return: the current TaskState.

getSubTasks()

Get the subtasks currently added to the ThreadTask. :rtype: std::vector< rw::common::ThreadTask::Ptr > :return: a vector of subtasks.

getThreadPool()

Get the ThreadPool that is used by this task currently.

Return type

rw::core::Ptr< rw::common::ThreadPool >

Returns

pointer to the ThreadPool.

idle()

Function is executed when the task becomes idle (new subtasks can be added in this function).

isNull()

checks if the pointer is null :rtype: boolean :return: Returns true if the pointer is null

isShared()

check if this Ptr has shared ownership or none ownership :rtype: boolean :return: true if Ptr has shared ownership, false if it has no ownership.

keepAlive()

Check is the task has keep alive option enabled. :rtype: boolean :return: true if task should be kept alive, false otherwise.

registerFailure(asNumpy)

Mark the task as a failure by registering an exception.

The user should override the #subTaskDone function in the parent task to either handle the exceptions appropriately or propagate them further on.

Parameters

e (Exception) – [in] an exception describing the problem.

run()

Function is the first function executed to do the actual work (new subtasks can

be added in this function).

setKeepAlive(enable)

Choose if the thread should exit automatically when all work and children has finished (this is the default).

Remember to set this to false when there is no more work to be done by the task, to allow the task to stop.

Parameters

enable (boolean) – [in] true if the thread should NOT finish automatically.

setThreadPool(pool)

Set which ThreadPool to use to do the actual execution of work. When execution is started the pool can not be changed anymore. :type pool: rw::core::Ptr< rw::common::ThreadPool > :param pool: [in] pointer to the pool :rtype: boolean :return: true if change was successful, false otherwise.

subTaskDone(subtask)
Function is executed each time a subtask has finished (new subtasks can be added

in this function). If #registerFailure is used to register failures in subtasks, this

function should handle or propagate the failures. The default implementation of this function is as follows:

for(const Exception& esubtask->getExceptions()) {

registerFailure(e);

}

Parameters

subtask (ThreadTask) – [in] the subtask that just finished.

property thisown

The membership flag

wait(previous)

Wait until state of task changes (blocking).

Remember to check if the new State is the desired (for instance DONE).

Parameters

previous (int) – [in] the previous state (wait for changes from this)

Return type

int

Returns

the new TaskState

waitUntilDone()

Wait until state of task changes to DONE (blocking).

class sdurw_common.sdurw_common.Timer(*args)

Bases: object

The timer class provides an easy to use platform independent timer

In Windows the expected resolution is approx. 16ms. In Linux the expected resolution is approx. 1ms

__init__(*args)

Overload 1:

Constructor

This implicitly starts the timer.


Overload 2:

constructor - initialize the timer to a specified value. This does not start the timer. :type timems: int :param timems: [in] time in ms


Overload 3:

constructor - initialize the timer to a specified value. This does not start the timer. :type hh: int :param hh: [in] hours :type mm: int :param mm: [in] minutes :type ss: int, optional :param ss: [in] seconds :type ms: int, optional :param ms: [in] milli seconds


Overload 4:

constructor - initialize the timer to a specified value. This does not start the timer. :type hh: int :param hh: [in] hours :type mm: int :param mm: [in] minutes :type ss: int, optional :param ss: [in] seconds :param ms: [in] milli seconds


Overload 5:

constructor - initialize the timer to a specified value. This does not start the timer. :type hh: int :param hh: [in] hours :type mm: int :param mm: [in] minutes :param ss: [in] seconds :param ms: [in] milli seconds

static currentTime()

Returns system clock in seconds

Warning: The date/time at which this timer counts from is platform-specific, so you should not use it for getting the calendar time. It’s really only meant for calculating wall time differences.

static currentTimeMs()

Returns system clock in milli-seconds

Warning: The date/time at which this timer counts from is platform-specific, so you should not use it for getting the calendar time. It’s really only meant for calculating wall time differences.

static currentTimeSec()

Returns system clock in hole seconds

Warning: The date/time at which this timer counts from is platform-specific, so you should not use it for getting the calendar time. It’s really only meant for calculating wall time differences.

static currentTimeUs()

Returns system clock in micro-seconds.

Warning: The date/time at which this timer counts from is platform-specific, so you should not use it for getting the calendar time. It’s really only meant for calculating wall time differences.

Notice: The timer cannot hold times longer than approx. 2100second.

getTime()

The time the timer has been running.

The time passed while the timer has been paused are not included in the running time. The timer is paused when pause() has been called and counting is resumed when resume() has been called.

It is perfectly OK and natural to call getTime() on a running timer, i.e. a timer that has not been paused.

A call of reset() resets the running time to zero.

Return type

float

Returns

Time in seconds

getTimeMs()

The time the timer has been running in mili seconds.

see getTime

Return type

int

Returns

Time in mili seconds

getTimeSec()

The time the timer has been running in hole seconds.

see getTime

Return type

int

Returns

Time in hole seconds

isPaused()

Returns true if the timer is paused :rtype: boolean :return: True is paused

pause()

Pause the timer

The timer stops counting. As long as the timer has not been resumed (see resume()) or restarted (see reset()) the timer value (see getTime()) will stay the same.

Is is OK to call pause() on a timer that has already been paused: The timer will just stay paused and nothing is changed.

reset()

Reset the timer

The timer is set back to zero and starts counting.

It is OK to call reset() on a timer that has already been started: The time will just be set back to zero again.

resetAndPause()

Resets and pauses the timer

The timer is set to zero and paused

It is OK to call reset() on a timer that has already been started: The time will just be set back to zero again.

resetAndResume()

Resets and stats the timer

Same as reset()

The timer is set to zero and starts counting

It is OK to call reset() on a timer that has already been started: The time will just be set back to zero again.

resume()

Resume the timer after a pause.

The timer starts counting again.

It is OK to call resume() on a timer that is already counting: The timer keeps counting and nothing is done.

static sleepMs(period)

Sleeps for a period of time

Parameters

period (int) – [in] the time in miliseconds to sleep

static sleepUs(period)

Sleeps for a period of time

Parameters

period (int) – [in] the time in microseconds to sleep

property thisown

The membership flag

toString(*args)

returns a string describing the time. The format of the time is described using format :type format: string, optional :param format: [in] the format is on the form:

hh:mm:ss –> 05:06:08 h:m:s –> 5:6:8

Return type

string

Returns

a formated time string

class sdurw_common.sdurw_common.TimerUtil

Bases: object

Access of the system clock so called wall time.

__init__()
static currentTime()

Returns system clock in seconds

Warning: The date/time at which this timer counts from is platform-specific, so you should not use it for getting the calendar time. It’s really only meant for calculating wall time differences.

static currentTimeMs()

Returns system clock in milli-seconds

Warning: The date/time at which this timer counts from is platform-specific, so you should not use it for getting the calendar time. It’s really only meant for calculating wall time differences.

static currentTimeUs()

Returns system clock in micro-seconds.

Warning: The date/time at which this timer counts from is platform-specific, so you should not use it for getting the calendar time. It’s really only meant for calculating wall time differences.

Notice: The timer cannot hold times longer than approx. 2100second.

static sleepMs(period)

Sleeps for a period of time

Parameters

period (int) – [in] the time in miliseconds to sleep

static sleepUs(period)

Sleeps for a period of time

Parameters

period (int) – [in] the time in microseconds to sleep

property thisown

The membership flag

sdurw_common.sdurw_common.TimerUtil_currentTime()

Returns system clock in seconds

Warning: The date/time at which this timer counts from is platform-specific, so you should not use it for getting the calendar time. It’s really only meant for calculating wall time differences.

sdurw_common.sdurw_common.TimerUtil_currentTimeMs()

Returns system clock in milli-seconds

Warning: The date/time at which this timer counts from is platform-specific, so you should not use it for getting the calendar time. It’s really only meant for calculating wall time differences.

sdurw_common.sdurw_common.TimerUtil_currentTimeUs()

Returns system clock in micro-seconds.

Warning: The date/time at which this timer counts from is platform-specific, so you should not use it for getting the calendar time. It’s really only meant for calculating wall time differences.

Notice: The timer cannot hold times longer than approx. 2100second.

sdurw_common.sdurw_common.TimerUtil_sleepMs(period)

Sleeps for a period of time

Parameters

period (int) – [in] the time in miliseconds to sleep

sdurw_common.sdurw_common.TimerUtil_sleepUs(period)

Sleeps for a period of time

Parameters

period (int) – [in] the time in microseconds to sleep

sdurw_common.sdurw_common.Timer_currentTime()

Returns system clock in seconds

Warning: The date/time at which this timer counts from is platform-specific, so you should not use it for getting the calendar time. It’s really only meant for calculating wall time differences.

sdurw_common.sdurw_common.Timer_currentTimeMs()

Returns system clock in milli-seconds

Warning: The date/time at which this timer counts from is platform-specific, so you should not use it for getting the calendar time. It’s really only meant for calculating wall time differences.

sdurw_common.sdurw_common.Timer_currentTimeSec()

Returns system clock in hole seconds

Warning: The date/time at which this timer counts from is platform-specific, so you should not use it for getting the calendar time. It’s really only meant for calculating wall time differences.

sdurw_common.sdurw_common.Timer_currentTimeUs()

Returns system clock in micro-seconds.

Warning: The date/time at which this timer counts from is platform-specific, so you should not use it for getting the calendar time. It’s really only meant for calculating wall time differences.

Notice: The timer cannot hold times longer than approx. 2100second.

sdurw_common.sdurw_common.Timer_sleepMs(period)

Sleeps for a period of time

Parameters

period (int) – [in] the time in miliseconds to sleep

sdurw_common.sdurw_common.Timer_sleepUs(period)

Sleeps for a period of time

Parameters

period (int) – [in] the time in microseconds to sleep

class sdurw_common.sdurw_common.VectorThreadTaskPtr(arg1=None, arg2=None)

Bases: list

This class is deprecated and is basically a wrapper around a list

__init__(arg1=None, arg2=None)
at(i)
back()
clear()

Remove all items from list.

empty()
front()
pop_back()
push_back(elem)
size()
sdurw_common.sdurw_common.ownedPtr(*args)

Overload 1:

A Ptr that takes ownership over a raw pointer ptr.


Overload 2:

A Ptr that takes ownership over a raw pointer ptr.


Overload 3:

A Ptr that takes ownership over a raw pointer ptr.


Overload 4:

A Ptr that takes ownership over a raw pointer ptr.


Overload 5:

A Ptr that takes ownership over a raw pointer ptr.


Overload 6:

A Ptr that takes ownership over a raw pointer ptr.


Overload 7:

A Ptr that takes ownership over a raw pointer ptr.


Overload 8:

A Ptr that takes ownership over a raw pointer ptr.


Overload 9:

A Ptr that takes ownership over a raw pointer ptr.


Overload 10:

A Ptr that takes ownership over a raw pointer ptr.


Overload 11:

A Ptr that takes ownership over a raw pointer ptr.