Login Form






Lost Password?
No account yet? Register
Home arrow Forums
ECharts
Welcome, Guest
Question about when machine constructor is called (0 viewing) 
Go to bottom Post Reply Favoured: 0
TOPIC: Question about when machine constructor is called
#355
Eric Cheung (Admin)
Admin
Posts: 24
graphgraph
User Offline Click here to see the profile of this user
Question about when machine constructor is called 1 Year ago  
I ran into a case where the machine constructor is called unexpectedly. Here is the code:

Code: :

  package examples; public machine ConstructorTest1 {     initial state S1;     state S2 concurrent {         state SS1Example0001();         state SS2[2]: Example0001();     }     transition S1 -      -> [ S2.SS1S2.SS2.NEW ]; }



And Example0001 is modified from the one in SVN slightly:

Code: :

  public machine Example0001 {     public Example0001() {         System.out.println("We are all born mad.  Some remain so.");     }     initial state S1;     state S2;     transition S1 - / System.out.println("Hello World!") -> S2; }



When run, the Example0001 constructor is called three times, where I would expect only twice: once for S2.SS1, and once for S2.SS2[0].

Code: :

  $ ./runExample ConstructorTest1.ech *** Running ConstructorTest1 We are all born mad.  Some remain so. We are all born mad.  Some remain so. We are all born mad.  Some remain so. Hello World! Hello World! *** Completed



Wonder why.

Thanks
Eric
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#356
Eric Cheung (Admin)
Admin
Posts: 24
graphgraph
User Offline Click here to see the profile of this user
Re:Question about when machine constructor is called 1 Year ago  
This alternative produces the expected behavior:

Code: :

  public machine ConstructorTest2 {     initial state S1;     state S2 concurrent {         state SS1Example0001();         state SS2[2]: Example0001();     }     transition S1 -      -> S2.SS2.NEW; }



Code: :

 $ ./runExample ConstructorTest2.ech *** Running ConstructorTest2 We are all born mad.  Some remain so. We are all born mad.  Some remain so. Hello World! Hello World! *** Completed



But from manual 3.15, it seems Test1 and Test2 should yield same behavior?

Thanks
Eric
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#357
Gregory W. Bond (User)
Expert Boarder
Posts: 81
graph
User Offline Click here to see the profile of this user
Re:Question about when machine constructor is call 1 Year ago  
it looks like SS1 is being re-created in the first example where it is explicitly referenced by the transition (this can be confirmed by looking at MachineCreation events in the log)

this appears to be a bug - i'll take a closer look
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop
Copyright © 2006-2009 echarts.org