[Tinyos-help] Re: "Uses" parameterized interfaces

Darren BISHOP d.bishop at cs.ucl.ac.uk
Tue Aug 15 05:44:13 PDT 2006


Try this:

module A {
    uses IF as IFB;
    uses IF as IFC;
}
implementation {
    bool iLikeAMore;
    ...
    task void some_task() {
        if (iLikeAMore)
            IFA.some_command();
        else
            IFB.some_command();
    }
}

configuration A {
}
implementation {
    components A, B, C;
    .
    .
    A.IFB -> B.IF;
    A.IFC -> C.IF;
    .
    .
}

You could also try 'using' a parameterized interface i.e. the opposite 
of providing one; combined with some enums, this might work:

configuration A {
}
implementation {
    components A, B, C;
    .
    .
    A.IF[B_IMPL] -> B;
    A.IF[C_IMPL] -> C;
    .
    .
}

This second suggestion is just an 'out-there' thought; prob best to 
stick with the first example as it is the recommend wiring.

Best regards,

Darren
Arijit Ghosh wrote:
> No that will not work.
>
> Each of the two components B and C "provides" the
> interface IF. Lets assume IF has a command
> some_command:
>
> interface IF {
>  command result_t some_command();
> }
>
> B and C provides their own implementation.
> Ex. in B, I have
>
> command result_t IF.some_command() {
>     /* Some implementation */
> }
>
> And in C:
> command result_t IF.some_command() {
>     /* Some different implementatio */
> }
>
> Now A wants to use the IF interface provided by B and
> C.
> How do I do it?
>   
>
> "Do the best you can, with what you have, where you are." -- Roosevelt
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com


More information about the Tinyos-help mailing list