#include <sxComponent.h>
Classes | |
class | PrivateData |
Public Types | |
enum | { Terminated = 0x01, PreActivated = 0x02, Activated = 0x04, Deactivated = 0x08, Error = 0x10, PreEvaluating = 0x20, AbortByUser = 0x40 } |
Public Member Functions | |
virtual bool | Work ()=0 |
Called to proceed the data. | |
virtual int | Type () const =0 |
Type of the component. | |
virtual bool | ConfigurePorts ()=0 |
Configure port for this component. | |
virtual bool | IsSource () const |
Return true for Source component. | |
virtual bool | IsProcessor () const |
Return true for Processor component. | |
virtual bool | IsSink () const |
Return true for Sink component. | |
virtual bool | IsPassive () const |
for passive component, return true for passive component, Work() won't be called data should be passed whenever requested. | |
virtual bool | IsMultipleInstanceAllowed () const |
return true if multiple instance is allowed | |
virtual bool | IsManager () const |
return true for manager component | |
virtual bool | PreEvaluation () |
virtual bool | OnEvaluate () |
Error evaluation. | |
virtual bool | PreActivation () |
Called just before starting the component. | |
virtual bool | PostDeactivation () |
called after finish executing component. | |
virtual bool | CheckConnections () const |
Return true if whole ports are connected. | |
virtual sxPacket * | DataRequested () |
return data packet if requested (on demand data) | |
virtual bool | OnCreate () |
Called after creation of the component. | |
virtual bool | OnDestroy () |
Called before destroying the component. | |
virtual bool | OnEnterWorkingLoop () |
called before entering process loop. | |
virtual void | OnExitWorkingLoop () |
called after finishing process loop. | |
virtual bool | Load (const QDomElement &comps, const QList< sxPort * > &portList) |
Load component from given xml structure of design file. | |
virtual bool | Save (QDomElement &comps) |
save component to xml structure of design file. | |
sxUiAbstractComponent * | UiComponent () const |
pointer to ui component | |
unsigned long | RunCount () const |
Return number of execution, ULONG_MAX for continuous run. | |
void | SetRunner (sxComponentRunner *runer) |
assign component runner | |
sxComponentRunner * | Runner () const |
QList< sxComponent * > | DownstreamComponents () const |
Get all downstream components. | |
bool | IsError () const |
Return true if component is in error state, otherwise return false. | |
void | ClearErrors () |
Clear error messages and it flags. | |
QString | ErrorMessage () const |
Get error message if in error state. | |
QString | ComponentId () const |
Return component id assigned to component. | |
QString | Description () const |
Get component description. | |
void | SetDescription (const QString &txt) |
Set component description. | |
bool | IsContinued () const |
return true if continuous running | |
int | State () const |
Retrieve component's state. | |
void | SetNetwork (sxNetwork *net) |
set network | |
sxNetwork * | Network () const |
bool | IsActivated () const |
Return true if component is in sxComponent::Activated state. | |
bool | IsTerminated () const |
Return true if component is in sxComponent::Terminated state. | |
double | GTimerToc () const |
qint64 | GTimerBase () const |
void | TimerTic () |
double | TimerToc () const |
void | DisplayMessage (const QString &msg, sx::MessageType type=sx::RegularMessage) |
bool | HasInput () const |
Return true if at least 1 input port is exists. | |
bool | HasOutput () const |
return true if at least 1 output port exist | |
sxInPort * | InputAt (int idx) const |
Get input port at given index. | |
int | InputCount () const |
Number of input ports. | |
sxOutPort * | OutputAt (int idx) const |
Get ouput port at given index. | |
int | OutputCount () const |
Get number of output ports. | |
sxOutPort * | FirstOutput () const |
First output port. | |
sxInPort * | FirstInput () const |
First input port. | |
void | ClearPorts () |
Clear data in ports. | |
bool | OpenPorts () |
Open output port(s). | |
bool | ClosePorts () |
Close output ports. | |
void | ResetStates () |
bool | Evaluate () |
bool | Activate (unsigned long rcount) |
Start component execution. | |
bool | Deactivate () |
Bring component into Deactivated state. | |
void | Terminate () |
Set component state to Terminated. | |
QString | LibraryName () const |
library name where this component belongs to | |
void | SetLibraryName (const QString &name) |
assign new library name | |
Protected Member Functions | |
virtual bool | SaveCustom (QDomElement &compNode) |
Save custom property. | |
virtual bool | LoadCustom (const QDomElement &compNode) |
Load custom property. | |
sxComponent (const QString &name, const QString &cap, sxUiAbstractComponent *ui) | |
void | SetErrorMessage (const QString &msg) |
Set error message. | |
void | SetComponentId (const QString &id) |
Assign component id (string type). | |
void | SetComponentId (quintptr id) |
Assign unique component id to this component. | |
void | SetState (int s) |
Set component state. | |
bool | IsAllInputsConnected () const |
return true if all input ports is connected. | |
bool | IsAnyInputConnected () const |
return true if at least one input ports is connected | |
bool | IsAllOutputsConnected () const |
Return true if all output ports is connected. | |
bool | IsAnyOutputConnected () const |
return true if at least one output is connected. | |
void | RemovePorts () |
Remove all connected ports. | |
void | AddPort (sxPort *p) |
Add new port. | |
sxOutPort * | AddOutputPort (const QString &cap, sx::DataType dtype) |
Add new output port. | |
sxInPort * | AddInputPort (const QString &cap) |
Allocate new input port. | |
sxTimer * | Timer () |
anonymous enum |
bool sxComponent::Activate | ( | unsigned long | rcount | ) |
Start component execution.
bring component into activated state.
rcount | run mode, ULONG_MAX for continuous running |
References Activated, ErrorMessage(), OpenPorts(), PreActivated, PreActivation(), SetErrorMessage(), and SXTR.
Referenced by sxNetwork::Start().
sxInPort * sxComponent::AddInputPort | ( | const QString & | cap | ) | [protected] |
Allocate new input port.
cap | caption of the port |
References AddPort(), sxCaptionItem::SetCaption(), and sxPort::SetComponent().
sxOutPort * sxComponent::AddOutputPort | ( | const QString & | cap, | |
sx::DataType | dtype | |||
) | [protected] |
Add new output port.
cap | caption of the port | |
dtype | data type associated to the port |
References AddPort(), sxCaptionItem::SetCaption(), sxPort::SetComponent(), and sxOutPort::SetDataType().
void sxComponent::AddPort | ( | sxPort * | port | ) | [protected] |
Add new port.
References sxPort::IsInput(), and sxPort::IsOutput().
Referenced by AddInputPort(), AddOutputPort(), and Load().
virtual bool sxComponent::ConfigurePorts | ( | ) | [pure virtual] |
Configure port for this component.
Override this method to allocate input/output port. This method will be called after component creation, but not during loading components from design file, since number of input/outputs is specified in the design.
Referenced by sxComponentLibrary::Create().
bool sxComponent::Deactivate | ( | ) |
Bring component into Deactivated state.
Whole ports will be closed.
References sxCaptionItem::Caption(), ClosePorts(), Deactivated, Error, PreEvaluating, State(), and Terminated.
Referenced by sxNetwork::Abort(), and sxNetwork::Start().
QList< sxComponent * > sxComponent::DownstreamComponents | ( | ) | const |
Get all downstream components.
References sxPort::Component(), sxOutPort::Connection(), sxConnection::Destination(), OutputAt(), and OutputCount().
Referenced by sxNetwork::SortComponents().
sxOutPort * sxComponent::FirstOutput | ( | ) | const |
sxInPort * sxComponent::InputAt | ( | int | idx | ) | const |
Get input port at given index.
This method assumed that given index is valid index (i.e. 0 to input's size - 1)
idx | index of port to be retrieve |
Referenced by OnEvaluate(), sxNetwork::Save(), and Save().
bool sxComponent::IsAllInputsConnected | ( | ) | const [protected] |
return true if all input ports is connected.
If no input port, this method will return false.
References HasInput().
Referenced by CheckConnections().
bool sxComponent::IsAllOutputsConnected | ( | ) | const [protected] |
Return true if all output ports is connected.
If no output port, this method return false.
References HasOutput().
bool sxComponent::IsPassive | ( | ) | const [virtual] |
for passive component, return true for passive component, Work() won't be called data should be passed whenever requested.
Please implement DataRequested()
Referenced by sxNetwork::Abort(), and sxNetwork::Stop().
bool sxComponent::Load | ( | const QDomElement & | node, | |
const QList< sxPort * > & | portList | |||
) | [virtual] |
Load component from given xml structure of design file.
References AddPort(), sxPort::findPort(), LoadCustom(), RemovePorts(), sxCaptionItem::SetCaption(), sxPort::SetComponent(), and SetDescription().
Referenced by sxNetwork::Load().
bool sxComponent::OnDestroy | ( | ) | [virtual] |
Called before destroying the component.
If delete component manually, this method won't be called
Referenced by sxComponentLibrary::Create(), sxNetwork::RemoveComponent(), and sxNetwork::RemoveComponents().
bool sxComponent::OnEnterWorkingLoop | ( | ) | [virtual] |
called before entering process loop.
this fuction live in the same thread with Work()
bool sxComponent::OnEvaluate | ( | ) | [virtual] |
Error evaluation.
Override this method to implement error checking. This method is called before starting component. Default implementation is check number of input channel and output channel for first input/output, check sample's delta among channel and transfer descriptor value to next component(s)
References sxCaptionItem::Caption(), sxPacket::Clone(), sxPacket::Drop(), sxPacketHeader::Get(), sxPacket::Header(), InputAt(), InputCount(), OutputAt(), OutputCount(), sxInPort::ReadConfiguration(), SetErrorMessage(), SXTR, and sxOutPort::Write().
void sxComponent::OnExitWorkingLoop | ( | ) | [virtual] |
called after finishing process loop.
this event live in the same thread with Work()
sxOutPort * sxComponent::OutputAt | ( | int | idx | ) | const |
Get ouput port at given index.
This method assumed that given index is valid (i.e. from 0 to output size - 1)
Referenced by ClearPorts(), ClosePorts(), DownstreamComponents(), OnEvaluate(), OpenPorts(), sxNetwork::Save(), and Save().
bool sxComponent::PostDeactivation | ( | ) | [virtual] |
bool sxComponent::PreActivation | ( | ) | [virtual] |
Called just before starting the component.
Reimplement this to do variable initialisation.
Referenced by Activate().
void sxComponent::RemovePorts | ( | ) | [protected] |
bool sxComponent::Save | ( | QDomElement & | comps | ) | [virtual] |
save component to xml structure of design file.
<component id="ididid"> <caption>text</caption> <description>text</description> .... <inputs> <> </inputs> <outputs> <> </outputs> <custom> <> </custom> <gui> <> </gui> </component>
References sxCaptionItem::Caption(), ComponentId(), Description(), InputAt(), InputCount(), LibraryName(), OutputAt(), OutputCount(), SaveCustom(), and Type().
Referenced by sxNetwork::Save().
bool sxComponent::SaveCustom | ( | QDomElement & | compNode | ) | [protected, virtual] |
void sxComponent::SetComponentId | ( | quintptr | id | ) | [protected] |
Assign unique component id to this component.
Usually address of this instance is used as an id. The id is used to determined the connection among components.
id | unique component id |
void sxComponent::SetComponentId | ( | const QString & | id | ) | [protected] |
void sxComponent::SetErrorMessage | ( | const QString & | msg | ) | [protected] |
Set error message.
msg | associated error message |
References Error.
Referenced by Activate(), and OnEvaluate().
void sxComponent::SetState | ( | int | s | ) | [protected] |
Set component state.
param s state (Terminated, Activated, etc)
virtual int sxComponent::Type | ( | ) | const [pure virtual] |
virtual bool sxComponent::Work | ( | ) | [pure virtual] |
Called to proceed the data.
Specify data processing step/procedure here.