PIP 5.5.3
Platform-Independent Primitives
Открытые члены | Открытые статические члены | Защищенные члены | Полный список членов класса
Класс PIConnection

Complex Input/Output point. Подробнее...

Граф наследования:PIConnection:
Inheritance graph
[см. легенду]

Открытые члены

 PIConnection (const PIString &name=PIString::fromAscii("connection"))
 Constructs connection with name "name", or with default name = "connection".
 
 PIConnection (const PIString &config, const PIString &name)
 Constructs connection and configure it from config file "config" from section "name".
 
 PIConnection (PIString *string, const PIString &name)
 Constructs connection and configure it from config content "string" from section "name".
 
bool configureFromConfig (const PIString &config, const PIString &name=PIString::fromAscii("connection"))
 Configure connection from config file "config" from section "name". Returns if configuration was successful. Подробнее...
 
bool configureFromString (PIString *string, const PIString &name=PIString::fromAscii("connection"))
 Configure connection from config content "string" from section "name". Returns if configuration was successful. Подробнее...
 
PIString makeConfig () const
 Returns config file section of current connection configuration.
 
PIIODeviceaddDevice (const PIString &full_path, PIIODevice::DeviceMode mode=PIIODevice::ReadWrite, bool start=false)
 Add device with full path "full_path", open mode "mode" to Device pool and connection. Подробнее...
 
bool removeDevice (const PIString &full_path)
 Remove device with full path "full_path" from connection. Подробнее...
 
void removeAllDevices ()
 Remove all device from connection. Подробнее...
 
PIIODevicedeviceByFullPath (const PIString &full_path) const
 Returns device with full path "full_path" or null if there is no such device.
 
PIIODevicedeviceByName (const PIString &name) const
 Returns device with name "name" or null if there is no such device.
 
PIVector< PIIODevice * > boundedDevices () const
 Returns all devices bounded to this connection.
 
PIPacketExtractoraddFilter (const PIString &name, const PIString &full_path_name, PIPacketExtractor::SplitMode mode=PIPacketExtractor::None)
 Add filter with name "name" to device with full path "full_path_name" or filter "full_path_name". Подробнее...
 
PIPacketExtractoraddFilter (const PIString &name, const PIIODevice *dev, PIPacketExtractor::SplitMode mode=PIPacketExtractor::None)
 Add filter with name "name" to device "dev".
 
PIPacketExtractoraddFilter (PIPacketExtractor *filter, const PIString &full_path_name)
 Add filter with "filter" to device "dev".
 
PIPacketExtractoraddFilter (PIPacketExtractor *filter, const PIIODevice *dev)
 Add filter with "filter" to device "dev".
 
bool removeFilter (const PIString &name, const PIString &full_path_name)
 Remove from filter with name "name" device with full path "full_path_name" or filter "full_path_name". Подробнее...
 
bool removeFilter (const PIString &name, const PIIODevice *dev)
 Remove from filter with name "name" device or filter "dev".
 
bool removeFilter (const PIString &name)
 Remove filter with name "name". Returns if filter was removed.
 
void removeAllFilters ()
 Remove all filters from connection.
 
PIVector< PIPacketExtractor * > filters () const
 Returns all filters of connection.
 
PIStringList filterNames () const
 Returns all filter names of connection.
 
PIPacketExtractorfilter (const PIString &name) const
 Returns PIPacketExtractor * assosiated with filter "name" or null if there is no such filter.
 
PIVector< PIIODevice * > filterBoundedDevices (const PIString &name) const
 Returns all devices bounded to filter "name".
 
bool addChannel (const PIString &name_from, const PIString &name_to)
 Add to connection channel from "name_from" to "name_to". Подробнее...
 
bool addChannel (const PIString &name_from, const PIIODevice *dev_to)
 Add to connection channel from "name_from" to "dev_to".
 
bool addChannel (const PIIODevice *dev_from, const PIString &name_to)
 Add to connection channel from "dev_from" to "name_to".
 
bool addChannel (const PIIODevice *dev_from, const PIIODevice *dev_to)
 Add to connection channel from "dev_from" to "dev_to".
 
bool removeChannel (const PIString &name_from, const PIString &name_to)
 Remove from connection channel from "name_from" to "name_to". Подробнее...
 
bool removeChannel (const PIString &name_from, const PIIODevice *dev_to)
 Remove from connection channel from "name_from" to "dev_to".
 
bool removeChannel (const PIIODevice *dev_from, const PIString &name_to)
 Remove from connection channel from "dev_from" to "name_to".
 
bool removeChannel (const PIIODevice *dev_from, const PIIODevice *dev_to)
 Remove from connection channel from "dev_from" to "dev_to".
 
bool removeChannel (const PIString &name_from)
 Remove from connection all channels from "name_from". Подробнее...
 
bool removeChannel (const PIIODevice *dev_from)
 Remove from connection all channels from "dev_from".
 
void removeAllChannels ()
 Remove from connection all channels.
 
PIVector< PIPair< PIString, PIString > > channels () const
 Returns all channels of this connection as full pathes or filter names pair array (from, to)
 
void addSender (const PIString &name, const PIString &full_path_name, float frequency, bool start=false)
 Add to connection sender with name "name" device with full path "full_path". Подробнее...
 
void addSender (const PIString &name, const PIIODevice *dev, float frequency, bool start=false)
 Add to connection sender with name "name" device "dev".
 
bool removeSender (const PIString &name, const PIString &full_path_name)
 Remove from sender with name "name" device with full path "full_path_name". Подробнее...
 
bool removeSender (const PIString &name, const PIIODevice *dev)
 Remove from sender with name "name" device "dev".
 
bool removeSender (const PIString &name)
 Remove sender with name "name", returns if sender was removed.
 
bool setSenderFixedData (const PIString &name, const PIByteArray &data)
 Set sender "name" fixed send data "data", returns if sender exists.
 
bool clearSenderFixedData (const PIString &name)
 Remove sender "name" fixed send data, returns if sender exists.
 
PIByteArray senderFixedData (const PIString &name) const
 Returns sender "name" fixed send data.
 
float senderFrequency (const PIString &name) const
 Returns sender "name" timer frequency, -1 if there is no such sender, or 0 if sender is not started yet.
 
void removeAllSenders ()
 Remove from connection all senders.
 
void startThreadedRead (const PIString &full_path_name)
 Start read thread of device with full path "full_path".
 
void startThreadedRead (const PIIODevice *dev)
 Start read thread of device "dev".
 
void startAllThreadedReads ()
 Start read threads of all Device pool device.
 
void startSender (const PIString &name)
 Start sender "name" timer.
 
void startAllSenders ()
 Start all senders timers.
 
void start ()
 Start all read threads and senders.
 
void stopThreadedRead (const PIString &full_path_name)
 Stop read thread of device with full path "full_path".
 
void stopThreadedRead (const PIIODevice *dev)
 Stop read thread of device "dev".
 
void stopAllThreadedReads ()
 Stop read threads of all Device pool device.
 
void stopSender (const PIString &name)
 Stop sender "name" timer.
 
void stopAllSenders ()
 Stop all senders timers.
 
void stop ()
 Stop all read threads and senders.
 
void destroy ()
 Stop connection and remove all devices.
 
bool isEmpty () const
 Returns if there are no devices in this connection.
 
PIDiagnosticsdiagnostic (const PIString &full_path_name) const
 Returns PIDiagnostics * assosiated with device with full path "full_path_name", name "full_path_name" or filter "full_path_name".
 
PIDiagnosticsdiagnostic (const PIIODevice *dev) const
 Returns PIDiagnostics * assosiated with device or filter "dev".
 
int writeByFullPath (const PIString &full_path, const PIByteArray &data)
 Write data "data" to device with full path "full_path" and returns result of write() function of device.
 
int writeByName (const PIString &name, const PIByteArray &data)
 Write data "data" to device with name "name" and returns result of write() function of device.
 
int write (PIIODevice *dev, const PIByteArray &data)
 Write data "data" to device "dev" and returns result of write() function of device.
 
- Открытые члены унаследованные от PIObject
 PIObject (const PIString &name=PIString())
 Создает PIObject с именем "name".
 
PIString name () const
 Возвращает имя объекта
 
virtual const char * className () const
 Возвращает имя класса объекта
 
virtual const char * parentClassName () const
 Возвращает имя родительского класса
 
bool debug () const
 Возвращает включен ли вывод piCoutObj для этого объекта
 
void setName (const PIString &name)
 Устанавливает имя объекта
 
void setDebug (bool debug)
 Включает или отключает вывод piCoutObj для этого объекта
 
PIVariant property (const char *name) const
 Возвращает свойство объекта по имени "name".
 
void setProperty (const char *name, const PIVariant &value)
 Устанавливает у объекта свойство по имени "name" в "value". Если такого свойства нет, оно добавляется
 
bool isPropertyExists (const char *name) const
 Возвращает присутствует ли свойство по имени "name".
 
PIStringList scopeList () const
 Возвращает цепочку наследования объекта (вместе с классом самого объекта)
 
void piDisconnect (const PIString &sig, PIObject *dest, void *ev_h)
 Разрывает все соединения от события "sig" к объекту "dest" и обработчику "ev_h".
 
void piDisconnect (const PIString &sig, PIObject *dest)
 Разрывает все соединения от события "sig" к объекту "dest".
 
void piDisconnect (const PIString &sig)
 Разрывает все соединения от события "sig".
 
bool isPIObject () const
 Возвращает действительный ли это PIObject (проверяет подпись)
 
template<typename T >
bool isTypeOf () const
 Возвращает действительный ли это наследник PIObject типа "T" (проверяет подпись и имя класса)
 
template<typename T >
T * cast () const
 Возвращает преобразование к типу T если это действительный наследник типа "T" (проверяет через isTypeOf()), или "nullptr".
 
void callQueuedEvents ()
 Выполнить все отложенные события от CONNECTU_QUEUED соединений
 
bool maybeCallQueuedEvents ()
 Если было хотя бы одно CONNECTU_QUEUED соединение с исполнителем this, то выполнить события Подробнее...
 
void deleteLater ()
 Пометить объект на удаление Подробнее...
 
void deleted (PIObject *o)
 Вызывается перед удалением объекта Подробнее...
 

Открытые статические члены

static PIVector< PIConnection * > allConnections ()
 Returns all connections in application.
 
static PIVector< PIIODevice * > allDevices ()
 Returns all devices in Device pool.
 
static bool setFakeMode (bool yes)
 Set Device pool fake mode to "yes" and returns previous mode.
 
static bool isFakeMode ()
 Returns if Device pool works in fake mode.
 
- Открытые статические члены унаследованные от PIObject
static void piDisconnect (PIObject *src, const PIString &sig, PIObject *dest, void *ev_h)
 Разрывает все соединения от события "sig" объекта "src" к объекту "dest" и обработчику "ev_h".
 
static void piDisconnect (PIObject *src, const PIString &sig, PIObject *dest)
 Разрывает все соединения от события "sig" объекта "src" к объекту "dest".
 
static void piDisconnect (PIObject *src, const PIString &sig)
 Разрывает все соединения от события "sig" объекта "src".
 
static PIObjectfindByName (const PIString &name)
 Returns PIObject* with name "name" or 0, if there is no object found.
 
static bool isPIObject (const PIObject *o)
 Возвращает действительный ли "o" PIObject (проверяет подпись)
 
template<typename T >
static bool isTypeOf (const PIObject *o)
 Возвращает действительный ли "o" наследник PIObject типа "T" (проверяет подпись и имя класса)
 

Защищенные члены

virtual void dataReceived (const PIString &from, const PIByteArray &data)
 Executes on data received from device with full path "from".
 
virtual void packetReceived (const PIString &from, const PIByteArray &data)
 Executes on packet received from filter with name "from".
 
virtual PIByteArray senderData (const PIString &sender_name)
 You should returns data for sender "sender_name".
 
- Защищенные члены унаследованные от PIObject
PIObjectemitter () const
 Возвращает PIObject* который вызвал это событие. Значение допустимо только из методов обработчиков событий
 
virtual void propertyChanged (const char *name)
 Виртуальная функция, вызывается после изменения любого свойства.
 

Events

void dataReceivedEvent (const PIString &from, const PIByteArray &data)
 Raise on data received from device with full path "from".
 
void packetReceivedEvent (const PIString &from, const PIByteArray &data)
 Raise on packet received from filter with name "from".
 
void qualityChanged (const PIIODevice *dev, PIDiagnostics::Quality new_quality, PIDiagnostics::Quality old_quality)
 Raise on diagnostic quality of device "device" changed from "old_quality" to "new_quality".
 

Дополнительные унаследованные члены

Подробное описание

Complex Input/Output point.

Synopsis

PIConnection provides abstract layer over physical devices, filtering and connecting data streams. Each PIConnection works through Device Pool, so several PIConnections can read from single physical device. General scheme:

Device pool concept

Device pool is static object, single for each application, which contains unique devices. Each PIConnection works with real devices through Device pool. Each device has assosiated thread for read and it can be started or stopped with PIConnection functions startThreadedRead() and stopThreadedRead().

Filters

PIConnection filter is a PIPacketExtractor and assosiated array of devices or other filters. When read thread is successfully read from device this data can be passed to one or more filters. Each filter has name and filter names should be unique. You can use this name for access to PIPacketExtractor* with function filter(), or get array of assosiated devices and filters with function filterBoundedDevices(). One filter can receive data from several sources, and can be bounded to several filters.

Diagnostics

PIConnection create PIDiagnostics for each device or filter. You can access to these objects with functions diagnostic().

Senders

PIConnection can send data to devices with named timers ("senders"). You can create sender or add device to sender with function addSender(). Each sender has internal timer and every tick execute virtual function senderData(). Returns value of this function sended to bounded devices. You can assign fixed send data to sender with function setSenderFixedData(). In this case sender will NOT execute senderData(), but send assigned data.

Configuration

You can create PIConnection from config file section or configure it later with function configureFromConfig(). Devices describes with its full pathes, for details see Creating devices by unambiguous string. Example:

Also PIConnection can create PIString with its configuration with function makeConfig(). This string can be directly inserted into the config file.

Методы

◆ configureFromConfig()

bool PIConnection::configureFromConfig ( const PIString config,
const PIString name = PIString::fromAscii ("connection") 
)

Configure connection from config file "config" from section "name". Returns if configuration was successful.

Warning: all devices, filters and channels removed before configure!

◆ configureFromString()

bool PIConnection::configureFromString ( PIString string,
const PIString name = PIString::fromAscii ("connection") 
)

Configure connection from config content "string" from section "name". Returns if configuration was successful.

Warning: all devices, filters and channels removed before configure!

◆ addDevice()

PIIODevice * PIConnection::addDevice ( const PIString full_path,
PIIODevice::DeviceMode  mode = PIIODevice::ReadWrite,
bool  start = false 
)

Add device with full path "full_path", open mode "mode" to Device pool and connection.

Returns pointer to device or null if device can not be created. If "start" is true, read thread is started immediately. Else, you can start read thread with functions startThreadedRead() or startAllThreadedReads(). By default, read thread doesn`t start

◆ removeDevice()

bool PIConnection::removeDevice ( const PIString full_path)

Remove device with full path "full_path" from connection.

Returns if device was removed. If there is no connection bounded to this device, it will be removed from Device pool

◆ removeAllDevices()

void PIConnection::removeAllDevices ( )

Remove all device from connection.

If there is no connection bounded to there devices, they removed from Device pool

◆ addFilter()

PIPacketExtractor * PIConnection::addFilter ( const PIString name,
const PIString full_path_name,
PIPacketExtractor::SplitMode  mode = PIPacketExtractor::None 
)

Add filter with name "name" to device with full path "full_path_name" or filter "full_path_name".

If there is no filter with name "name", connection create new with split mode "mode" and bound to it device "full_path_name" or filter "full_path_name". If filter with name "name" already exists, device "full_path_name" or filter "full_path_name" add to this filter. This function returns PIPacketExtractor * assosiated with this filter
Attention! "mode" is altual olny if new filter was created!

◆ removeFilter()

bool PIConnection::removeFilter ( const PIString name,
const PIString full_path_name 
)

Remove from filter with name "name" device with full path "full_path_name" or filter "full_path_name".

If there is no devices bounded to this filter, it will be removed. Returns if device was removed

◆ addChannel()

bool PIConnection::addChannel ( const PIString name_from,
const PIString name_to 
)

Add to connection channel from "name_from" to "name_to".

"name_from" and "name_to" can be full pathes of devices or device names or filter names. Returns false if there if no such device or filter, else create channel and returns true

◆ removeChannel() [1/2]

bool PIConnection::removeChannel ( const PIString name_from,
const PIString name_to 
)

Remove from connection channel from "name_from" to "name_to".

"name_from" and "name_to" can be full pathes of devices or filter names. Returns false if there if no such device or filter, else remove channel and returns true

◆ removeChannel() [2/2]

bool PIConnection::removeChannel ( const PIString name_from)

Remove from connection all channels from "name_from".

"name_from" can be full path of device or filter name. Returns false if there if no such device or filter, else remove channels and returns true

◆ addSender()

void PIConnection::addSender ( const PIString name,
const PIString full_path_name,
float  frequency,
bool  start = false 
)

Add to connection sender with name "name" device with full path "full_path".

If there is no sender with name "name", connection create new, bound to it device "full_path_name" and start sender timer with frequency "frequency". If sender with name "name" already exists, device "full_path_name" add to this sender If "start" is true, sender is started immediately. Else, you can start sender with functions startSender()
Attention! "frequency" is actual olny if new sender was created!

◆ removeSender()

bool PIConnection::removeSender ( const PIString name,
const PIString full_path_name 
)

Remove from sender with name "name" device with full path "full_path_name".

If there is no devices bounded to this sender, it will be removed. Returns if sender was removed