1 /****************************************************************************
2 ** ui.h extension file, included from the uic-generated form implementation.
4 ** If you wish to add, delete or rename slots use Qt Designer which will
5 ** update this file, preserving your code. Create an init() slot in place of
6 ** a constructor, and a destroy() slot in place of a destructor.
7 *****************************************************************************/
10 Subscriber *tabSub[50];
12 Publisher *tabPub[50];
16 void MulticlipForm::init()
18 memset(tabSub,0,sizeof(tabSub));
19 memset(tabPub,0,sizeof(tabPub));
23 QTimer *timer = new QTimer(this);
24 connect( timer, SIGNAL(timeout()), SLOT(Timer()));
25 timer->start( 500, FALSE );
29 void MulticlipForm::addPublisher()
31 PublishersListBox->insertItem( QString::number(np), 0 );
38 void MulticlipForm::deletePublisher()
40 QString text=PublishersListBox->currentText();
41 if(PublishersListBox->currentItem()!=-1 && !text.isEmpty()){
43 pub=NPublisher-1-PublishersListBox->currentItem() ;
44 PublishersListBox->removeItem( PublishersListBox->currentItem() );
45 tabPub[pub]->Destroy();
47 for(int i=pub;i+1<NPublisher;i++) tabPub[i]=tabPub[i+1];
48 tabPub[NPublisher]=NULL;
54 void MulticlipForm::GotoP( )
56 QString name = QString::number(np);
58 int shap=ShapeP->currentItem();
59 int color=ColorP->currentItem();
61 tabPub[NPublisher]=new Publisher();
62 tabPub[NPublisher]->Create(name,shap,color,strength);
67 void MulticlipForm::closeEvent( QCloseEvent *e )
70 for(i=0;i<NPublisher;i++){
74 for(i=0;i<NSubscriber;i++){
81 void rcvCallBack(ORTERcvInfo *rcvInfo,u_char status)
89 sscanf((char*)rcvInfo->data,"%i %i %i %i",&a,&b,&c,&d);
90 rect.setCoords(a,b,c,d);
91 topic=(char *)rcvInfo->subsTopic;
92 type=(char *)rcvInfo->subsTypeName;
93 if(strcmp(topic,"Ellipse")==0)top=0;
94 if(strcmp(topic,"Rectangle")==0)top=1;
95 if(strcmp(topic,"Triangle")==0)top=2;
96 if(strcmp(type,"Blue")==0)typ=0;
97 if(strcmp(type,"Green")==0)typ=1;
98 if(strcmp(type,"Red")==0)typ=2;
99 if(strcmp(type,"Black")==0)typ=3;
101 for(int i=0;i<NSubscriber;i++){
102 if(tabSub[i]->topS==top && tabSub[i]->typS==typ){
103 (tabSub[i]->m_mainFrm)->setCaption(tabSub[i]->strTitle);
104 (tabSub[i]->m_mainFrm)->SetShapeRect(rect);
109 for(int i=0;i<NSubscriber;i++){
112 for(int j=0;j<NPublisher;j++){
113 if(tabSub[i]->topS!=tabPub[j]->top || tabSub[i]->typS!=tabPub[j]->typ){
118 if(NPublisher==0 || dead==NPublisher){
119 QString name=tabSub[i]->strTitle+" deadline ";
120 (tabSub[i]->m_mainFrm)->setCaption(name);
127 void MulticlipForm::GotoS( )
129 QString name =QString::number(ns);
131 int shap=ShapeS->currentItem();
132 int color=ColorS->currentItem();
164 NtpTime minimumSeparation,deadline;
166 tabSub[NSubscriber]=new Subscriber();
167 tabSub[NSubscriber]->Create(name,shap,color);
168 ORTEAppCreate(&(tabSub[NSubscriber]->app));
169 NtpTimeAssembFromMs(minimumSeparation,0,0);
170 NtpTimeAssembFromMs(deadline, 5, 0);
171 h_sub=ORTEAppSubsAdd(tabSub[NSubscriber]->app,topic,type, &minimumSeparation,&deadline,rcvCallBack);
174 void MulticlipForm::addSubscriber()
177 SubscribersListBox->insertItem( QString::number(ns), 0 );
183 void MulticlipForm::deleteSubscriber()
185 QString text=SubscribersListBox->currentText();
186 if(SubscribersListBox->currentItem()!=-1 && !text.isEmpty()){
188 pub=NSubscriber-1-SubscribersListBox->currentItem() ;
189 SubscribersListBox->removeItem( SubscribersListBox->currentItem() );
190 tabSub[pub]->Destroy();
192 for(int i=pub;i+1<NSubscriber;i++) tabSub[i]=tabSub[i+1];
193 tabSub[NSubscriber]=NULL;
200 void MulticlipForm::keyPressEvent( QKeyEvent *e )
202 if(Qt::Key_Delete==e->key() ) {
203 if( focusWidget ()==PublishersListBox)deletePublisher();
204 if( focusWidget ()==SubscribersListBox)deleteSubscriber();
210 void MulticlipForm::Timer()
213 for(i=0;i<NPublisher;i++){
214 if((tabPub[i]->m_mainFrm)->getClose()==1){
215 PublishersListBox->setCurrentItem (NPublisher-1-i);
219 for(i=0;i<NSubscriber;i++){
220 if((tabSub[i]->m_mainFrm)->getClose()==1){
221 SubscribersListBox->setCurrentItem (NSubscriber-1-i);