Search the web
Sign In
New User? Sign Up
AgileEmbedded · Agile Embedded
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want to share photos of your group with the world? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Understanding Model-Conductor-Hardware pattern   Message List  
Reply | Forward Message #142 of 464 |
Re:Understanding Model-Conductor-Hardware pattern

--- In AgileEmbedded@yahoogroups.com, Thad Smith <ThadSmith@...> wrote:
>
> > So, to answer your central question, the value of the Conductor in
> > Model-Conductor-Hardware is that it allows the hardware control
logic
> > to be segregated from the business logic.
>
> So do two separate modules, business and hardware.

I think I understand what you mean when you say two separate modules,
but perhaps I don't. We think the value of three modules (Model,
Conductor, and Hardware) over a two module approach is this. If
hardware logic is contained in the hardware layer at all, then it can
only be tested by exercising the actual hardware (something we're
trying to avoid). The MCH approach allows all logic to live in the
realm of automated unit tests that do not require the hardware to be
present to be run. The Hardware layer consists of getters and setters
and ISR handlers. Decoupling the hardware logic from the hardware
allows it to be unit tested in a automated test suite - verifying that
when an interrupt occurs the expected subsequent operations happen in
response (for example, reads from Hardware and operations in the
Model). The Hardware layer is as thin as possible (i.e. no or little
logic) so that hardware logic can be tested independently. Decoupling
is good, so we further separate business logic from hardware logic; it
makes for better design and increased testability.


> > By testing the Conductor,
> > hardware conditions and event handling (interrupts, etc.) can be
> > tested apart from the data handling and number crunching logic of
the
> > Model.
>
> So do two modules, with a test driver for each.

In the system we've put together, we do eventually use a test driver -
in a system test that exercises the full hardware. Otherwise, a unit
test suite tests the hardware logic (C) and business logic (M) apart
from physical hardware.


> What I can imagine from your and Mr. Grenning's examples is that the
two
> interfaces, the MC and CH interfaces, are chosen such that
> 1. The MC interface is in terms of the natural core logic units and
concepts,
> somewhat independent of the particular hardware interface.
> 2. The CH interface is closely aligned to the particular hardware
interface,
> keeping the H layer thin.
>
> With that scheme, the C layer can translate units (as suggested in
Mr. Grenning's
> message), do hardware dependent sequencing, like your example of
taking a reading
> when the timer expires, and probably isolating the core logic from
at the lower
> levels of timing service. One of the keys to that type of mapping,
I think, would
> be determining the proper division between the core logic and the
conductor, since
> it doesn't seem as obvious as the division between the model and the
presenter in
> the MVP pattern: should input averaging be done in the C or M layer,
for example.
>
> Am I getting warm?

If I understand what you're saying, yes, you're getting warm in that
you're working to decouple distinct functions. In my mind, the
division is clear and unit conversion would go in the Model. The
Conductor's purpose is to decouple hardware logic from business logic.
There always seems to be unexpected gains in decoupling distinct
functionality. The MCH pattern encourages that decoupling. In my
temperature example, I see plenty to test. The Conductor would do the
following things:
1. Handle a timing interrupt (loop and check a flag in the Hardware)
2. Tell Hardware to initiate A-to-D
3. Handle the A-to-D complete interrupt
4. Fetch raw values from the A/D unit
5. Call a function in the Model with those values to convert them to a
meaningful number per the temperature sensor's formula.
6. Call a function in the Model to convert the value calculated in (5)
into proper units for the value to be displayed.

All this functionality is "conducting" - coordinating hardware events
and passing data to the right places. There's a lot going on in the
above. The Hardware and Model can be faked out so that order and
correctness of 1-6 can be tested. We can also test the calculation and
unit conversion methods (business logic) in the Model separately from
the Hardware and Conductor. With system tests, we can test that the
Hardware layer is interfacing with the actual hardware properly.


> As a suggestion to presentation, it helps me to see guidelines for
drawing the
> borders. Specifying an interface at some natural or logical level
seems to me to
> be a key here. The example in the paper I read basically had a
pass-through
> wrapper for the conductor, as I recall, so it wasn't obvious what
the benefit of
> such a layer would be. I think a more complex example, showing the
separation of
> the different abstractions at the two interfaces (and corresponding
conductor
> processing) would help me, as well as potentially others.

You're absolutely right. The example we have in the paper doesn't
really illustrate the Conductor's purpose well in that there is only
pass-thru operations and no real hardware logic. The intent of the
Conductor is that it operates much like a Presenter in MVP - receiving
events and dispatching a series of operations that interact with the
Hardware and Model in response. Having this dialogue with you causes
me to see that there is yet some understanding in our heads that we've
not yet effectively communicated.

In the end, MCH is what we've developed. It's worked well for us on
several projects and the basic ideas have precendent in MVP. None of
this is to say that it can't be further refined or entirely replaced.






Sat Jan 13, 2007 12:48 am

mkarlesky
Online Now Online Now
Send Email Send Email

Forward
Message #142 of 464 |
Expand Messages Author Sort by Date

I just joined this group after seeing a message on comp.software-eng by Mike Karlesky. I followed some links he provided and found an interesting article,...
Thad Smith
thadsmith3
Offline Send Email
Jan 10, 2007
6:22 am

Thad, I'll try to answer your questions as well as I can. We're pretty excited that there's some discussion starting on this topic. Pardon the length of what...
Michael Karlesky
mkarlesky
Online Now Send Email
Jan 11, 2007
4:11 pm

... I think the something (Hardware or Conductor) might want to hide the hardware a little more by normalizing the temperature. so the model deals with...
James Grenning
jwgrenning
Offline Send Email
Jan 11, 2007
5:14 pm

... The intent of the MHC pattern is to allow for maximum automated testability; it does this by decoupling hardware from code. In MVP the same thing is...
mkarlesky
Online Now Send Email
Jan 12, 2007
3:50 am

I like the comparison of MHC to MVP and have found that analogy useful before. I agree that you want a very thin layer covering the hardware. I also think...
James Grenning
jwgrenning
Offline Send Email
Jan 12, 2007
4:55 am

... from current website: » Unity – embedded unit test framework for C (released 2008) http://sourceforge.net/projects/embunity/ Doesn't seem to have any...
marktxx
Offline Send Email
Apr 27, 2008
6:51 pm

... » Unity – embedded unit test framework for C (released 2008) http://sourceforge.net/projects/embunity/ Follow the link above and select the 'Code' menu...
Greg Williams
willi297
Offline Send Email
Apr 28, 2008
3:36 am

... That makes sense. ... I can understand that benefit to creating a Presenter in MVP. ... So do two separate modules, business and hardware. ... So do two...
Thad Smith
thadsmith3
Offline Send Email
Jan 12, 2007
2:22 am

... logic ... I think I understand what you mean when you say two separate modules, but perhaps I don't. We think the value of three modules (Model, Conductor,...
mkarlesky
Online Now Send Email
Jan 13, 2007
12:48 am

... A thin hardware interface layer, the same, I think, as you use for the H layer, plus the rest in the business layer / application logic. ... I understand...
Thad Smith
thadsmith3
Offline Send Email
Jan 13, 2007
6:47 pm

... the ... understand ... Yes. This is the case. Separating M and C makes things easier to test. The separation ensures that there's no coupling between the...
mkarlesky
Online Now Send Email
Jan 21, 2007
3:12 am

In AgileEmbedded@yahoogroups.com <mailto:AgileEmbedded%40yahoogroups.com>, James Grenning <grenning@...> ... The purpose of the hardware layer is to provide...
Rick
rick_clements
Offline Send Email
Jan 13, 2007
8:06 pm

... board.) ... Rick, what you're describing is what we would call unit tests, system tests, and acceptance tests. The MCH pattern makes it possible to unit ...
mkarlesky
Online Now Send Email
Jan 21, 2007
3:53 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help