Skip to Content.
Sympa Menu

notify-dpml - svn commit: r1575 - in development/laboratory/planet/components/fsm: basic/src/main/net/dpml/fsm/basic demo/trafficlight

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: niclas AT netcompartner.com
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: svn commit: r1575 - in development/laboratory/planet/components/fsm: basic/src/main/net/dpml/fsm/basic demo/trafficlight
  • Date: Mon, 24 Jan 2005 11:26:47 +0100

Author: niclas
Date: Mon Jan 24 11:26:47 2005
New Revision: 1575

Modified:

development/laboratory/planet/components/fsm/basic/src/main/net/dpml/fsm/basic/StateImpl.java

development/laboratory/planet/components/fsm/basic/src/main/net/dpml/fsm/basic/StateMachineImpl.java

development/laboratory/planet/components/fsm/basic/src/main/net/dpml/fsm/basic/TransitionComponent.java
development/laboratory/planet/components/fsm/demo/trafficlight/build.xml
Log:
Getting the StateMachineImpl to work.

Modified:
development/laboratory/planet/components/fsm/basic/src/main/net/dpml/fsm/basic/StateImpl.java
==============================================================================
---
development/laboratory/planet/components/fsm/basic/src/main/net/dpml/fsm/basic/StateImpl.java
(original)
+++
development/laboratory/planet/components/fsm/basic/src/main/net/dpml/fsm/basic/StateImpl.java
Mon Jan 24 11:26:47 2005
@@ -100,11 +100,17 @@
public boolean equals( Object o )
{
if( o == null )
+ {
+ System.out.println( "fail null" );
return false;
- if( ! (o instanceof StateImpl) )
+ }
+ if( ! (o instanceof State) )
+ {
+ System.out.println( "fail instanceof" );
return false;
- StateImpl other = (StateImpl) o;
- return m_identity.equals( other.m_identity );
+ }
+ State other = (State) o;
+ return m_identity.equals( other.getIdentity() );
}

public int hashCode()

Modified:
development/laboratory/planet/components/fsm/basic/src/main/net/dpml/fsm/basic/StateMachineImpl.java
==============================================================================
---
development/laboratory/planet/components/fsm/basic/src/main/net/dpml/fsm/basic/StateMachineImpl.java
(original)
+++
development/laboratory/planet/components/fsm/basic/src/main/net/dpml/fsm/basic/StateMachineImpl.java
Mon Jan 24 11:26:47 2005
@@ -56,10 +56,19 @@
*/
public void trigger( Object source, String commandString )
{
+ if( m_currentState == null )
+ return;
+
Transition transition = null;
synchronized( this )
{
Collection bucket = (Collection) m_crossIndex.get(
m_currentState );
+ if( bucket == null )
+ { // if the returned bucket is null, it means there is an
internal
+ // error, as it should not be possible to set the current state
+ // to a state that is not part of the statemachine.
+ throw new InternalError( "Current state is corrupt:" +
m_currentState );
+ }
Iterator iterator = bucket.iterator();
while( iterator.hasNext() )
{
@@ -91,7 +100,6 @@
bucket = new TreeSet();
bucket.add( transition );
m_crossIndex.put( begin, bucket );
-System.out.println( m_crossIndex );
}
}

@@ -192,6 +200,8 @@
{
synchronized( this )
{
+ if( m_crossIndex.get( initialState ) == null )
+ throw new IllegalStateException( initialState + " is not
part of this StateMachine" );
m_currentState = initialState;
m_currentState.entry();
}

Modified:
development/laboratory/planet/components/fsm/basic/src/main/net/dpml/fsm/basic/TransitionComponent.java
==============================================================================
---
development/laboratory/planet/components/fsm/basic/src/main/net/dpml/fsm/basic/TransitionComponent.java
(original)
+++
development/laboratory/planet/components/fsm/basic/src/main/net/dpml/fsm/basic/TransitionComponent.java
Mon Jan 24 11:26:47 2005
@@ -39,7 +39,7 @@
import net.dpml.fsm.TransitionRule;

/**
- * @metro.component name="transition" lifestyle="transient" collection="hard"
+ * @metro.component name="transition" lifestyle="singleton" collection="hard"
* @metro.service type="net.dpml.fsm.Transition"
*/
public class TransitionComponent
@@ -80,7 +80,6 @@
State endState = (State) man.lookup( "end" );
m_endState = endState;
StateMachine sm = (StateMachine) man.lookup( "fsm" );
-System.out.println( "ADDING!!!" );
sm.addTransition( this );
m_rule = (TransitionRule) man.lookup( "rule" );


Modified:
development/laboratory/planet/components/fsm/demo/trafficlight/build.xml
==============================================================================
--- development/laboratory/planet/components/fsm/demo/trafficlight/build.xml
(original)
+++ development/laboratory/planet/components/fsm/demo/trafficlight/build.xml
Mon Jan 24 11:26:47 2005
@@ -15,7 +15,7 @@

<x:component name="timer" class="net.dpml.fsm.trafficlight.Timer" >
<x:dependencies>
- <x:dependency key="initial-state" source="state-red" />
+ <x:dependency key="initial-state" source="red" />
</x:dependencies>
</x:component>

@@ -27,30 +27,30 @@
</x:parameters>
</x:component>

- <x:component name="state-red"
class="net.dpml.fsm.basic.StateComponent" />
+ <x:component name="red" class="net.dpml.fsm.basic.StateComponent" />

- <x:component name="state-yellow"
class="net.dpml.fsm.basic.StateComponent" />
+ <x:component name="yellow" class="net.dpml.fsm.basic.StateComponent" />

- <x:component name="state-green"
class="net.dpml.fsm.basic.StateComponent" />
+ <x:component name="green" class="net.dpml.fsm.basic.StateComponent" />

- <x:component name="transition-red-to-green"
class="net.dpml.fsm.basic.TransitionComponent" activation="true">
+ <x:component name="red-to-green"
class="net.dpml.fsm.basic.TransitionComponent" activation="true">
<x:dependencies>
- <x:dependency key="begin" source="state-red" />
- <x:dependency key="end" source="state-green" />
+ <x:dependency key="begin" source="red" />
+ <x:dependency key="end" source="green" />
</x:dependencies>
</x:component>

- <x:component name="transition-yellow-to-red"
class="net.dpml.fsm.basic.TransitionComponent" activation="true">
+ <x:component name="yellow-to-red"
class="net.dpml.fsm.basic.TransitionComponent" activation="true">
<x:dependencies>
- <x:dependency key="begin" source="state-yellow" />
- <x:dependency key="end" source="state-red" />
+ <x:dependency key="begin" source="yellow" />
+ <x:dependency key="end" source="red" />
</x:dependencies>
</x:component>

- <x:component name="transition-green-to-yellow"
class="net.dpml.fsm.basic.TransitionComponent" activation="true">
+ <x:component name="green-to-yellow"
class="net.dpml.fsm.basic.TransitionComponent" activation="true">
<x:dependencies>
- <x:dependency key="begin" source="state-green" />
- <x:dependency key="end" source="state-yellow" />
+ <x:dependency key="begin" source="green" />
+ <x:dependency key="end" source="yellow" />
</x:dependencies>
</x:component>




  • svn commit: r1575 - in development/laboratory/planet/components/fsm: basic/src/main/net/dpml/fsm/basic demo/trafficlight, niclas, 01/24/2005

Archive powered by MHonArc 2.6.24.

Top of Page