31.01.2014 Views

Ph.D. - geht es zur Homepage der Informatik des Fachbereiches 3 ...

Ph.D. - geht es zur Homepage der Informatik des Fachbereiches 3 ...

Ph.D. - geht es zur Homepage der Informatik des Fachbereiches 3 ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 8. openETCS Domain Framework<br />

Similar to the CDataFlow execution by CEVCState, the ::std::thread is used to start<br />

the method in a separated thread. Its implementation is quite simple and can be found in<br />

Listing D.5 in Appendix D.<br />

It only execut<strong>es</strong> a while-loop as long the internal Boolean attribute m_bStarted is true. This<br />

can only turn into false if the CEVCStateMachine instance is explicitly stopped by the Stop()<br />

method or if an exception is thrown in the executed current EVC Mode m_pCurrentState or<br />

rather in its data flows. If the execution of the current EVC Mode in Line 6 is stopped due to<br />

a Mode transition or Application Level switch, the while-loop simple starts in its next run the<br />

new active CEVCState object or with the new m_CurrentApplicationLevel or even with a<br />

new combination of both.<br />

To stop the execution, only the attribute m_bStarted has to be set to false, which informs<br />

the current thread about the stop requ<strong>es</strong>t and waits for the state thread to terminate by the<br />

::std::thread:join() method in Listing D.6.<br />

8.6.5. DMI Implementation<br />

The CDMIQWidget implementation is quite simple and mainly treats the update of the displayed<br />

widgets for inputs and outputs. Any attached observer is notified by its CEVCStateMachine<br />

object via the Update() method that the contents or visibility state of one or more CDMIInput<br />

or CDMIOutput object of the current subject CDMISubject has changed or that even the<br />

complete subject was changed. The latter is the case if the ETCS mode and/or application<br />

level was changed. A changed subject always means that the input and output widgets<br />

(m_InputWidgets and m_OutputWidgets) have to be rearranged. Since this includ<strong>es</strong> the<br />

deletion of all existing input and output widgets and the creation of the new on<strong>es</strong>, this proc<strong>es</strong>s<br />

should be avoided in cas<strong>es</strong>, where only the value of CDMIOutput objects of the current<br />

CDMISubject were modified by the data flow calculation. Otherwise, this would delete any<br />

input of the driver that was already entered but not yet activated via the corr<strong>es</strong>ponding<br />

QPushButton. Accordingly, the CDMIQWidget observer always stor<strong>es</strong> the pointer to the<br />

last used CDMISubject in the m_pLastSubject aggregation (see Figure 8.5). Only, if in the<br />

execution of Update() the last subject is not identical to the current subject, the input and<br />

output widgets are rearranged. Otherwise, only the (displayed) valu<strong>es</strong> of the m_OutputWidgets<br />

are updated from m_Outputs in the DMI subject.<br />

Another but more minor aspect of the DMI implementation, is the fact that Qt 4 do<strong>es</strong> not<br />

accept chang<strong>es</strong> of GUI elements from other threads than the one running the Qt event loop [59].<br />

The event loop is started from the main() function because the corr<strong>es</strong>ponding openETCS C++<br />

generator (see Chapter 9) only generat<strong>es</strong> the instantiation of domain framework typ<strong>es</strong> and the<br />

starting of the CEVCStateMachine object. The CDMIQWidget Update() method is called from<br />

the current data flow thread (see Subsection 8.6.2), which is not the main thread. Therefore,<br />

the Update() method cannot change GUI elements of CDMIQWidget directly. The solution<br />

is again to make use of Qt 4’s signal and slot mechanism: The real update implementation<br />

is moved to the Qt slot UpdatedSlot(), which is connected [59] with the signal Updated().<br />

The method Update() then only emits the signal Updated() to call the slot with the update<br />

implementation but then in the thread of the Qt event loop.<br />

154

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!