Manual Practical Statecharts in C/C++: Quantum Programming for Embedded Systems with CDROM

Free download. Book file PDF easily for everyone and every device. You can download and read online Practical Statecharts in C/C++: Quantum Programming for Embedded Systems with CDROM file PDF Book only if you are registered here. And also you can download or read online all Book PDF file that related with Practical Statecharts in C/C++: Quantum Programming for Embedded Systems with CDROM book. Happy reading Practical Statecharts in C/C++: Quantum Programming for Embedded Systems with CDROM Bookeveryone. Download file Free Book PDF Practical Statecharts in C/C++: Quantum Programming for Embedded Systems with CDROM at Complete PDF Library. This Book have some digital formats such us :paperbook, ebook, kindle, epub, fb2 and another formats. Here is The CompletePDF Book Library. It's free to register here to get Book file PDF Practical Statecharts in C/C++: Quantum Programming for Embedded Systems with CDROM Pocket Guide.

Errata Errata for the first printing June Errata for the second and subsequent printings October Code Updates The following maintenance releases contain all bug fixes mentioned in the Errata, regardless of the book printing. Paperback , PDF see below. Most online book sellers, such as amazon. Errata for the first printing June You can also download this software free of chargedirectly from IAR Systems www.

At this point your screen should look similar to the screenshot shown inFigure 1.

Practical Statecharts in C/C++: Quantum Programming for Embedded Systems with CDROM by Miro Samek

To start the Flash programming process, select the Project Debug menu, or simplyclick the Debug button see Figure 1. The IAR Workbench shouldrespond by showing the Flash programming progress bar for several seconds, as shownin Figure 1. You canstart playing the game either by clicking the Go button in the debugger or you canclose the debugger and reset the board by pressing the Reset button.

You can edit the files and recompile the applicationat a click of a button F7. You accomplish this by loading the workspaceek-lm3s In the ev-lm3s Unless indicated otherwise in thischapter, you can browse the code in either the DOS version or the EV-LM3Sversion, because the application source code is identical in both. The complete main. NOTETo explain code listings, I place numbers in parentheses at the interesting lines in the leftmargin of the listing.

I then use these labels in the left margin of the explanation section thatimmediately follows the listing. Occasionally, to unambiguously refer to a line of a particularlisting from sections of text other than the explanation section, I use the full reference con-sisting of the listing number followed by the label. For example, Listing 1. Listing 1. This header file contains the specific adaptation of QP to the given processor, operating system, and compiler, which is called a port. I will discuss this header file in the upcoming Section 1. This header file is located in the application directory.

The QP event-driven platform is a collection of components, such as the QEP eventprocessor that executes state machines according to the UML semantics and the QFreal-time framework that implements the active object computing model. Activeobjects in QF are encapsulated state machines each with an event queue, a separatetask context, and a unique priority that communicate with one anotherasynchronously by sending and receiving events, whereas QF handles all the details ofthread-safe event exchange and queuing.

Within an active object, the events areprocessed by the QEP event processor sequentially in a run-to-completion RTC fashion, meaning that processing of one event must necessarily complete beforeprocessing the next event. See also Section 6. Here the storage is provided at compile time through the statically allocated arrays of immutable const pointers to events, because QF event queues hold just pointers to events, not events themselves. Each event queue of an active object can have a different size, and you need to decide this size based on your knowledge of the application. Event queues are discussed in Chapters 6 and 7.

Each event pool www.

Practical Statecharts in C/C++: Quantum Programming for Embedded Systems with CDROM

To avoid wasting memory by using oversized blocks for small events, the QF framework can manage up to three event pools of different block sizes for small, medium, and large events. The QF real-time framework supports two event delivery mechanisms: the simpledirect event posting to active objects and the more advanced mechanism calledpublish-subscribe that decouples event producers from the consumers.

In the publish-subscribe mechanism, active objects subscribe to events by the framework. Eventproducers publish the events to the framework. Upon each publication request, theframework delivers the event to all active objects that had subscribed to that eventtype. One obvious implication of publish-subscribe is that the framework muststore the subscriber information, whereas it must be possible to handle multiplesubscribers to any given event type.

The event delivery mechanisms are describedin Chapters 6 and 7. The subscriber lists remember which active objects have subscribed to which events. The parameters of this function are the pointer to the event pool storage, the size of this storage,www. You can call this function up to three times to initialize up to three event pools. For instance, the small block-size pool must be initialized before the medium block-size pool.

The parameters of this function are the pointer to the subscriber-list array and the dimension of this array. The useof this macro simplifies the code because it allows me to eliminate many defineconstants that otherwise I would need to provide for the dimensions of various arrays. I can simply hard-code the dimension right in the definition of an array, which is theonly place that I specify it. The function takes the following parameters: the pointer to the active object structure, the priority of the active object, the pointer to its event queue, the dimension length of that queue, and three other parameters that I explain in Chapter 7 they are not relevant at this point.

I like to keep the code and data of every active object strictly encapsulated within itsown C-file. For example, all code and data for the active object Ship are encapsulated inthe file ship. The frameworkexecutes the application by calling your code, not the other way around. In the DOS version of the www. In general, the decomposition of a problem into active objects is not trivial.

Embedded Systems Programming Lesson 0: Getting Started

As usualin any decomposition, your goal is to achieve possibly loose coupling among theactive object components ideally no sharing of any resources , and you also strivefor minimizing the communication in terms of the frequency and size of exchangedevents. I applied the simplest object-oriented technique ofidentifying objects, which is to pick the frequently used nouns in the problemspecification. From Section 1. However,not every state machine in the system needs to be an active object with a separatetask context, an event queue, and a unique priority level , and merging them is a validoption when performance or space is needed.

As an example of this idea, I ended upmerging the Mines into the Tunnel active object, whereas I preserved the Mines asindependent state machine components of the Tunnel active object. Getting Started with UML State Machines and Event-Driven Programming 17The next step in the event-driven application design is assigning responsibilities andresources to the identified active objects.

The general design strategy for avoidingsharing of resources is to encapsulate each resource inside a dedicated active object andto let that object manage the resource for the rest of the application. That way, insteadof sharing the resource directly, the rest of the application shares the dedicatedactive object via events. So, for example, I decided to put the Tunnel active object in charge of the display.

With some understanding of the responsibilities and resource allocations to activeobjects I can move on to devising the various scenarios of event exchanges amongthe objects. Perhaps the best instrument to aid the thinking process at this stage is theUML sequence diagram, such as the diagram depicted in Figure 1. The explanation sectionimmediately following the diagram illuminates the interesting points. Horizontally arranged boxesrepresent the various objects participating in the scenario, whereas heavy borders indicateactive objects. As usual in the UML, the object name is underlined.

Time flows down thepage along the vertical dashed lines descending from the objects. Events are represented ashorizontal arrows originating from the sending object and terminating at the receiving object. Optionally, thin rectangles around instance lines indicate focus of control. I then use these labels in the left margin of the explanation section that immediatelyfollows the diagram. Occasionally, to unambiguously refer to a specific element of a partic-ular diagram from sections of text other than the explanation section, I use the full referenceconsisting of the figure number followed by the label.

For example, Figure 1. This event is generated by the QF framework from the system time tick interrupt at a rate of 30 times per second, which is needed to drive a smooth animation of the display. The publish-subscribe event delivery in QF is described in Chapter 6. First, Tunnel redraws the entire display from the current frame buffer. This action, performed 30 times per second, provides the illusion of animation of the display. Next, the Tunnel clears the frame buffer and starts filling it up again for the next time frame. The Tunnel advances the tunnel walls by one step and copies the walls to the frame buffer.

The parameters of this event are the current x, y coordinates of the Ship, which are the starting point for the Missile. This determination depends on the type of the Mine. The Mine provides the score earned for destroying this particular mine as the parameter of this event. Even though the sequence diagram in Figure 1.

More important, you should start getting the general ideaabout the thinking process that goes into designing an event-driven system withactive objects and events. Getting Started with UML State Machines and Event-Driven Programming 21The best-known mechanism for handling such modal behavior is through statemachines because a state machine makes the behavior explicitly dependent on both theevent and the state of an object.

Chapter 2 introduces UML state machine conceptsmore thoroughly. The explanation section immediately following the diagram illuminatesthe interesting points. In the UML notation the state nodes are represented as rectangles with rounded cor- ners. The name of the state appears in bold type in the name compartment at the top of the state. Optionally, right below the name, a state can have an internal transition compart- ment separated from the name by a horizontal line. State transitions are represented as arrows originating at the boundary of the source state and pointing to the boundary of the target state.

At a min- imum, a transition must be labeled with the triggering event. Optionally, the trigger can be followed by event parameters, a guard, and a list of actions. Such transition designates the first active state after the state machine object is created. Subscribing to an event means that the framework will deliver the specified event to the Missile active object every time the event is published to the framework.

Resources and Tools for the Book

Chapter 7 describes the implementation of the publish-subscribe event delivery in QF. In practice, the actions areoften written in the programming language used for coding the particular state machine. Inall state diagrams in this book, I assume the C programming language. Internal transitions are simple reactions to events performed without a change of state.

An internal transition, as well as a regular transition, can have a guard condition, enclosed in square brackets. Guard condition is a Boolean expression evaluated at runtime. If the guard evaluates to TRUE, the transition is taken. In this particular case, the guard condition checks whether the x-coordinate propagated by the Missile speed is still visible on the screen. If so, the actions are executed.

Please note that the bitmap of the explosion changes as the explosion counter gets bigger. This transition is taken after the animation of the explosion completes.

Practical Statecharts in C/C++: Quantum Programming for Embedded Systems with CDROM

This state machineintroduces the profound concept of hierarchical state nesting. The power of statenesting derives from the fact that it is designed to eliminate repetitions that otherwisewould have to occur. One of the main responsibilities of the Ship active object is to maintain the current positionof the Ship. Butsuch repetitions would bloat the state machine and, more important, would representmultiple points of maintenance both in the diagram and the code.

Hierarchical state nesting remedies the problem. I know many have broadband Internet and could download the source and the information on website but…. The book itself is in two parts the first covers UML state charts, real-time etc.

The second part introduces the Quantum methods and ideas. This is an event- message type system. By coincidence whilst write this review there was a brief flurry of messages on comp. There were only a few replies but everyone liked the method and had used it on at least one real world project.

As for the book itself: I like it.