How to use multiple interfaces instances of the same type
How to use multiple interfaces instances of the same type
08.12.2008 21:26
Hello,
i have some problems with using multiple instances of one interface.
Based on the DishWasherSystem i want to add a second motor to the application. The type of the motor should be selectable too. So in my test application i have a interface with the instance itsMotor and one with itsMotor2. Now i have selected itsMotor to AC type and itsMotor2 to DC type.
The state chart of the application is updated with calls to Motor_on(me->itsMotor2) and Motor_off(me->itsMotor2).
The problem is, that the application will not differ between AC and DC motor now. Both motors are active as DC motors! I think the final type (AC/DC) of both motors depends on some random and the creation sequence.
After some code browsing i think i have found the mistake:
AC_DishWasherBuilder.c:
static void initRelations(AC_DishWasherBuilder* const me)
{
DishWasher_Init(&(me->itsDishWasher), me->ric_reactive.myTask);
FrontPanel_Init(&(me->itsFrontPanel), me->ric_reactive.myTask);
AC_Init(&(me->itsMotor));
DC_Init(&(me->itsMotor2));
FrontPanel_setItsDishWasher(&(me->itsFrontPanel), &(me->itsDishWasher));
DishWasher_setItsMotor(&(me->itsDishWasher), &(me->itsMotor._Motor));
FrontPanel_setItsDishWasher(&(me->itsFrontPanel2), &(me->itsDishWasher));
DishWasher_setItsMotor(&(me->itsDishWasher), &(me->itsMotor2._Motor));
}
Insteaf of setting the correct itsMotor2 to the Application, Rhapsody calls
DishWasher_setItsMotor(&(me->itsDishWasher), &(me->itsMotor2._Motor));
instead of
DishWasher_setItsMotor2(&(me->itsDishWasher), &(me->itsMotor2._Motor));
The DishWasher_setItsMotor2 method is well generated in the DishWasher source.
Is there any property i have to set, or just some modelling error?
Thanks for some help
Sebastian
Re: How to use multiple interfaces instances of the same type
09.12.2008 15:54
Ho Sebastian
There seems to be an error in your story. In the first part you say:
The state chart of the application is updated with calls to Motor_on(me->itsMotor2) and Motor_off(me->itsMotor2).
Is that a mistake that you use me->itsMotor2 twice? I'd expect one of them to be different.
Walter
Re: How to use multiple interfaces instances of the same type
09.12.2008 16:36
Hi Walter,
thanks for the fast reply. I think this is a small misunderstanding.
I added these methods to to entry/exit action of the dishwasher state "on".
Action on entry:
Motor_on(me->itsMotor);
Motor_on(me->itsMotor2);
Action on exit:
Motor_off(me->itsMotor);
Motor_off(me->itsMotor2);
Re: How to use multiple interfaces instances of the same type
10.12.2008 12:14
Hi Sebastian
Looks like a real error you got there. I'll transfer it to Telelogic/IBM.
greetz
Walter

