00001 #ifndef SXNETWORK_H_INCLUDED
00002 #define SXNETWORK_H_INCLUDED
00003
00004 #include <QThread>
00005 #include "sxObject.h"
00006 class sxInPort;
00007 class sxOutPort;
00008 class sxConnection;
00009 class sxComponent;
00010 class sxComponentLibrary;
00011
00015 typedef struct tagSXPacketLifeTime
00016 {
00017 sxComponent * comp;
00018 QString gen_id;
00019 qint64 ltime_usec;
00020 } SXPacketLifeTime;
00021
00025 class SX_SDKEXPORT sxNetwork : public sxCaptionItem
00026 {
00027 public:
00028 virtual ~sxNetwork();
00029 virtual sxInPort * CreateInputPort() const;
00030 virtual sxOutPort * CreateOutputPort() const;
00031 virtual sxConnection * CreateConnection();
00032 virtual sxComponent * CreateComponent(const QString& lname,
00033 int type, bool loadMode);
00034 virtual void ExecutionStarted();
00035 virtual void ExecutionFinished();
00036 virtual bool SaveCustom(QDomElement & root);
00037 virtual bool LoadCustom(const QDomElement & root);
00038 virtual void AddPacketLifeTime(const SXPacketLifeTime & ltime);
00039 virtual void DisplayMessage(const QString& msg, sx::MessageType type = sx::RegularMessage);
00040
00041 sxNetwork(const QString& cap = QString());
00042 QString ErrorMessages() const;
00043 QString FileName() const;
00044 void SetFileName(const QString& fname);
00045 bool HasComponent() const;
00046 void AddComponent(sxComponent * comp);
00047 int ComponentCount() const;
00048 sxComponent * ComponentAt(int idx) const;
00049 void SetComponentLibraries(QList<sxComponentLibrary *> * libraries);
00050 QList<sxComponentLibrary *> * ComponentLibraries() const;
00051 void SetRunMode(sx::RunMode mode);
00052 sx::RunMode RunMode() const;
00053 void SetRunParam(unsigned long param);
00054 unsigned long RunParam() const;
00055 void SetData(QVariant d);
00056 QVariant Data() const;
00057
00058 bool Load(const QString& fname = QString());
00059 bool Save(const QString& fname = QString());
00060 void RemoveComponents();
00061 void RemoveComponent(sxComponent * comp);
00062 void SortComponents();
00063 sxComponent * FindComponent(const QString& lname, int type) const;
00064 QList<SXPacketLifeTime> PacketsLifeTimeList() const;
00065 void RaiseError();
00066 void RaiseError(const QString& errmsg);
00067
00068 bool IsError() const;
00069 bool IsRunning() const;
00070 bool IsEvaluating() const;
00071 bool Start();
00072 void Pause();
00073 void Resume();
00074 bool Stop(unsigned long timeout = ULONG_MAX);
00075 bool Evaluate();
00076 void WaitResumed();
00077 bool IsPaused() const;
00078 bool WaitFinished(unsigned long timeout = ULONG_MAX);
00079 bool Abort();
00080
00081
00082 double TimerToc() const;
00083 qint64 TimerBase() const;
00084 private:
00085 class PrivateData;
00086 void TimerTic();
00087
00088 PrivateData * d_p;
00089 };
00090
00091
00092
00093
00094 class NetworkExecutionThread : public QThread
00095 {
00096 Q_OBJECT
00097 protected:
00098 void run();
00099 private slots:
00100 void executionFinished();
00101 void executionStarted();
00102 public:
00103 NetworkExecutionThread();
00104 virtual ~NetworkExecutionThread();
00105
00106 QList<sxComponent *> * xCompList;
00107 sx::RunMode xRunMode;
00108 unsigned long xRunParam;
00109 sxNetwork * xNetwork;
00110 };
00111
00112 #endif // SXNETWORK_H_INCLUDED