00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00028
00030
00031 #define YASAGUI_ENVIRONMENTWINDOW_INCLUDE
00032
00033
00035 #include "mainwindow.h"
00036 #include "widgets.h"
00037 #include "task.h"
00038 #include "environment.h"
00039 #include "plugins.h"
00040
00041 class YSchedulerPlugIns;
00044 class YEnvironmentFrame : public YObjectFrame
00045 { Q_OBJECT
00046 QScrollView scrollview;
00047 public: YEnvironmentFrame(QWidget *parent, YFrameArgs &args) :
00048 YObjectFrame(args),
00049 scrollview(parent)
00050 {}
00051 virtual int InitInstance();
00052 virtual QWidget* GetMainWidget() { return &scrollview; }
00053 static YFrame* CreateEnvironmentFrame(QWidget *parent, YFrameArgs &args)
00054 {
00055 return new YEnvironmentFrame(parent, args);
00056 }
00057 };
00058
00059
00060
00062 class YExecutiveStringList : public YStringList
00063 { Q_OBJECT
00064 public: YExecutiveStringList(YExecutivePlugIns *set) : YStringList(set) { }
00065 };
00066
00068 class YExecutiveWidget : public YTextComboWidget
00069 { Q_OBJECT
00070 YExecutiveStringList executivelist;
00071 public: YExecutiveWidget(YEnvironment *environment, QWidget *parent) :
00072 YTextComboWidget(environment, parent),
00073 executivelist( & YExecutivePlugIns::GetExecutivePlugIns() )
00074 {
00075
00076
00077 executivelist.AddItem(0, MSGP_ENVIRONMENT_EXECUTIVE_UNDEFINED, false);
00078 connect( &executivelist, SIGNAL(StringListChanged()), this, SLOT(ExecutiveListChanged() ) );
00079 ExecutiveListChanged();
00080 }
00081 public slots:
00082 virtual void UpdateWidget();
00084 virtual void UpdateValue(const QString &e);
00085
00086 void ExecutiveListChanged()
00087 { clear();
00088 insertStringList(executivelist);
00089 setCurrentItem( executivelist.FindIndex( ((YEnvironment*)object)->GetExecutive() ) );
00090 }
00091 };
00092
00094 class YGCCCompilerOptionsWidget : public YStringWidget
00095 { Q_OBJECT
00096 public: YGCCCompilerOptionsWidget(YEnvironment *e, QWidget *parent) :
00097 YStringWidget(e, parent) { UpdateWidget(); }
00098 public slots:
00099 virtual void UpdateWidget()
00100 {
00101 setEnabled( ((YEnvironment*)object)->GetExecutive() );
00102 if ( ((YEnvironment*)object)->GetGCCCompilerOptions() != text() )
00103 setText( ((YEnvironment*)object)->GetGCCCompilerOptions().GetContent() );
00104 }
00105 virtual void UpdateValue( const QString &t)
00106 {
00107 if ( ((YEnvironment*)object)->GetGCCCompilerOptions() != t )
00108 ((YEnvironment*)object)->SetGCCCompilerOptions( text() );
00109 }
00110 };
00111
00112
00114 class YExecutiveFeatureListWidget : public YTextWidget
00115 { Q_OBJECT
00116 YExecutivePlugIn *executive;
00117 public: YExecutiveFeatureListWidget(YEnvironment *e, QWidget *parent) : YTextWidget(e,parent),
00118 executive(0)
00119 { setReadOnly(true);
00120 setText(MSGP_ENVIRONMENT_EXECUTIVE_UNDEFINED);
00121 }
00122 public slots:
00123 virtual void UpdateWidget()
00124 {
00125 YExecutivePlugIn *newexecutive=((YEnvironment*)object)->GetExecutive();
00126 setEnabled( newexecutive);
00127 if ( executive != newexecutive )
00128 {
00129 executive = newexecutive;
00130 if ( newexecutive )
00131 {
00132 clear();
00133 QStringList list=executive->GetFeatureList();
00134 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
00135 {
00136 insertLine( (*it) );
00137 }
00138 if ( executive->GetDescription().length() )
00139 {
00140 insertLine("\n");
00141 insertLine(MSGP_EXECUTIVE_DESCRIPTION);
00142 insertLine(executive->GetDescription());
00143 }
00144 }
00145 else
00146 {
00147 setText(MSGP_ENVIRONMENT_EXECUTIVE_UNDEFINED);
00148 }
00149 }
00150 }
00151
00152 virtual void UpdateValue() { }
00153 };
00154
00155
00157 class YSchedulingTimeWidget : public YYasaTimeWidget
00158 { Q_OBJECT
00159 public: YSchedulingTimeWidget(YEnvironment *e, QWidget *parent) : YYasaTimeWidget(e, parent)
00160 { UpdateWidget();
00161 updateDisplay(); }
00162 public slots:
00163 virtual void UpdateWidget()
00164 {
00165 setEnabled( ((YEnvironment*)object)->GetExecutive() && ((YEnvironment*)object)->GetExecutive()->GetSchedulingTimeSupport() );
00166 if ( GetYasaTime() != ((YEnvironment*)object)->GetSchedulingTime() )
00167 SetYasaTime( ((YEnvironment*)object)->GetSchedulingTime());
00168 }
00169 virtual void UpdateValue(YASA_TIME value) { ((YEnvironment*)object)->SetSchedulingTime( value ); }
00170 protected:
00171 virtual QString mapValueToText(int v) { if ( v==YTIME::YASA_TIME_MIN) return QString( MSGP_ENVIRONMENT_SCHEDULING_TIME_UNSET );
00172 return QString::number(v); }
00173 virtual int mapTextToValue(bool *ok) { if ( text()==MSGP_ENVIRONMENT_SCHEDULING_TIME_UNSET ) return YTIME::YASA_TIME_MIN;
00174 return text().toInt(ok); }
00175 };
00176
00178 class YSynchronizationOffsetWidget : public YYasaTimeWidget
00179 { Q_OBJECT
00180 public: YSynchronizationOffsetWidget(YEnvironment *e, QWidget *parent) : YYasaTimeWidget(e, parent)
00181 { UpdateWidget();
00182 updateDisplay(); }
00183 public slots:
00184 virtual void UpdateWidget()
00185 {
00186 setEnabled( ((YEnvironment*)object)->GetExecutive() && ((YEnvironment*)object)->GetExecutive()->GetSynchronizationOffsetSupport() );
00187 if ( GetYasaTime() != ((YEnvironment*)object)->GetSynchronizationOffset() )
00188 SetYasaTime( ((YEnvironment*)object)->GetSynchronizationOffset() );
00189 }
00190 virtual void UpdateValue(YASA_TIME value) { ((YEnvironment*)object)->SetSynchronizationOffset(value ); }
00191 protected:
00192 virtual QString mapValueToText(int v) { if ( v==YTIME::YASA_TIME_MIN) return QString( MSGP_ENVIRONMENT_SYNCHRONIZATION_OFFSET_UNSET );
00193 return QString::number(v); }
00194 virtual int mapTextToValue(bool *ok) { if ( text()==MSGP_ENVIRONMENT_SYNCHRONIZATION_OFFSET_UNSET ) return YTIME::YASA_TIME_MIN;
00195 return text().toInt(ok); }
00196 };
00197
00200 class YSchedulerListViewItem : public YListViewItem
00201 { Q_OBJECT
00202 public: YSchedulerListViewItem(YObject *o, QListView *parent, QListViewItem *after=0) :
00203 YListViewItem( o, parent, after)
00204 {
00205 connect( ((YEnvironment*)o->GetSet()->GetParent() ), SIGNAL( UpdateObject() ) ,
00206 this, SLOT ( EnvironmentChanged() ) );
00207 UpdateObject(o);
00208 }
00209 YSchedulerListViewItem(YObject *o, QListViewItem *parent, QListViewItem *after=0) :
00210 YListViewItem( o, parent, after)
00211 {
00212 connect( ((YEnvironment*)o->GetSet()->GetParent() ), SIGNAL( UpdateObject() ) ,
00213 this, SLOT ( EnvironmentChanged() ) );
00214 UpdateObject(o);
00215 }
00216 protected:QString key(int column, bool ascending) const
00217 {
00218 switch (column)
00219 {
00220
00221 case 0: {
00222 int index=GetObject()->GetSet()->FindItemIndex( GetObject() );
00223 return YString::Justify( QString::number(index) );
00224 }
00225
00226 case 3: return YString::Justify( ((YScheduler*)object)->GetTimerTick().GetVisibleContentString() );
00227 }
00228 return text(column);
00229 Q_UNUSED(ascending);
00230 }
00231 public slots:
00232 void UpdateObject(YObject *o);
00235 void EnvironmentChanged() { UpdateObject(object); }
00236 };
00237
00238
00240 class YSchedulerListView : public YListView
00241 { Q_OBJECT
00242 public: YSchedulerListView(YSchedulerSet *s, QWidget *parent, const QString &title) :
00243 YListView(s,parent,title)
00244 {}
00245 virtual YListViewItem* CreateNewItem(QListViewItem *parent, YObject *object, QListViewItem *after=0)
00246 { if ( parent )
00247 return new YSchedulerListViewItem(object,parent,after);
00248 else
00249 return new YSchedulerListViewItem(object,this,after);
00250 }
00251 virtual int InitInstance()
00252 {
00253 addColumn(MSGP_ENVIRONMENT_SCHEDULER);
00254 addColumn(MSGP_ENVIRONMENT_CALCPREEMPTIONTIME);
00255 addColumn(MSGP_ENVIRONMENT_TIMERTICK);
00256 return YListView::InitInstance();
00257 }
00258 public slots:
00259 void UpdateObject(YObject *o)
00260 {
00261 setEnabled( ((YEnvironment*)o)->GetExecutive() );
00262 }
00263 };
00264
00265
00267 class YSchedulerStringList : public YStringList
00268 { Q_OBJECT
00269 public: YSchedulerStringList(YSchedulerPlugIns *set) : YStringList(set) { }
00270 };
00271
00273 class YTickEnvironmentWidget : public YYasaTimeWidget
00274 { Q_OBJECT
00275 YListView *schedulerlistview;
00276 public: YTickEnvironmentWidget(YObject *environment, QWidget *parent, YListView *schedulerlist) :
00277 YYasaTimeWidget(0, parent),
00278 schedulerlistview(schedulerlist)
00279 { UpdateWidget();
00280 Q_UNUSED(environment);
00281 }
00282 YScheduler* GetCurrentScheduler() const
00283 {
00284 YListViewItem *item=(YListViewItem*)schedulerlistview->currentItem();
00285 YScheduler *scheduler=0;
00286 if ( item )
00287 scheduler=(YScheduler*)item->GetObject();
00288 return scheduler;
00289 }
00290 public slots:
00291 virtual void UpdateWidget()
00292 { YASA_TIME time=YTIME::YASA_TIME_MIN;
00293 YScheduler *scheduler=GetCurrentScheduler();
00294 if ( scheduler )
00295 time=scheduler->GetTimerTick();
00296 if ( GetYasaTime() != time )
00297 SetYasaTime(time);
00298 }
00299 virtual void UpdateValue(YASA_TIME value)
00300 {
00301 YScheduler *scheduler=GetCurrentScheduler();
00302 if ( scheduler )
00303 {
00305 if ( scheduler->GetTimerTick().GetContent() != value )
00306 {
00307 if ( value )
00308 scheduler->SetTimerTick( value );
00309 else
00310 scheduler->DeriveTimerTick();
00311 }
00312 }
00313 }
00314 };
00315
00316
00317
00319 class YSchedulerListViewGroup : public QGroupBox, public YWidget
00320 { Q_OBJECT
00321 protected:
00322 YScheduler *scheduler;
00323 YListView *listview;
00324 QHBox *hbox;
00325 QLineEdit *cpuinfo;
00326 YSchedulerStringList schedulerlist;
00327 QComboBox *schedulercombo;
00328 QComboBox *calcpreemptiontimecombo;
00329 YTickEnvironmentWidget *timertickwidget;
00330 public: YSchedulerListViewGroup(YEnvironment *e, QWidget *parent) :
00331 QGroupBox(1,Horizontal, MSGP_ENVIRONMENT_SCHEDULERS, parent),
00332 YWidget( e ),
00333 scheduler(0),
00334 listview(0),
00335 hbox(0),
00336 schedulerlist( & YSchedulerPlugIns::GetSchedulerPlugIns() ),
00337 schedulercombo(0),
00338 calcpreemptiontimecombo(0)
00339 {
00340 connect( e, SIGNAL( UpdateObject() ), this, SLOT( UpdateWidget() ) );
00341 setAlignment(AlignHCenter);
00342 }
00343 virtual int InitInstance();
00344 virtual QWidget* GetWidget() { return this; }
00345 int CreateWidgets(YSet *set, QWidget *parent);
00346 public slots:
00347
00348 void SchedulerListChanged()
00349 {
00350 schedulercombo->clear();
00351 schedulercombo->insertStringList(schedulerlist);
00352 UpdateWidgets( listview->GetCurrentItem() );
00353 }
00354
00355 virtual void UpdateWidgets(QListViewItem *currentitem);
00356 virtual void ListViewEmpty() { UpdateWidgets(0); }
00357
00359 void SchedulerChanged(int index);
00360
00362 void CalcPreemptionTimeChanged(int index);
00363
00364 virtual void UpdateWidget()
00365 {
00366 UpdateWidgets( listview->currentItem() );
00367
00368 }
00369
00370 };
00371
00372
00373
00374
00376 #endif // ifndef YASAGUI_ENVIRONMENTWINDOW_INCLUDE