Shop OBEX P1 Docs P2 Docs Learn Events
stamp.util.os.Event — Parallax Forums

stamp.util.os.Event

bxgirtenbxgirten Posts: 79
edited 2006-10-05 16:47 in General Discussion
Was the Event class removed from the stamp.util.os package? I was playing with JBotInterface and the compiler couldn't resolve the reference.

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-07-23 20:29
    Can't remember it ever had an Event class. Only Task and TaskManager classes.

    Sure it isn't from another package?

    regards peter
  • bxgirtenbxgirten Posts: 79
    edited 2005-07-23 21:04
    Where are my manners? Here's the sample JBot code:
  • bxgirtenbxgirten Posts: 79
    edited 2005-07-23 21:05
    Here's the exploded view of the source code:

    package JBot;

    import stamp.core.*;
    import stamp.util.os.*;

    /**
    * J-Bot wheel control interface
    * <p>
    * Defines methods that J-Bot wheel control classes must provide.
    *
    * @version 2.1 03/12/03 Use new Task status support
    * @version 2.0 12/12/02 Use Event synchronization
    * @version 1.0 10/2/02
    * @author Parallax Inc.
    */

    public abstract class JBotInterface {
    protected Event startEvent ;
    protected Event nextEvent = Event.nullEvent ;
    protected Event oneTimeEvent = Event.nullEvent ;

    static final public int continuousForward = 32760 ;
    static final public int continuousBackward = -32760 ;
    static final public int continuousLeft = continuousForward ;
    static final public int continuousRight = continuousBackward ;

    /**
    * Set Event that is to be notified when a movement starts.
    *
    * @param event Event to be notified when movement starts. Can be null.
    */
    public JBotInterface ( Event event ) {
    startEvent = Event.checkEvent(event);
    }

    /**
    * Setup (current) task to wait for end of movement
    *
    * @param state next task state
    */
    public void wait ( int state ) {
    Task waitingTask = Task.getCurrentTask () ;
    waitingTask.nextState ( state ) ;

    if ( waitingTask.taskStatus()==Task.taskRunning) {
    waitingTask.suspend () ;
    oneTimeEvent = waitingTask ;
    }
    }

    /**
    * Set event to notify when movement is started. May be null.
    *
    * @param event Event to notify when movement is started
    *
    * @returns prior event
    */
    public Event setStartEvent ( Event event ) {
    Event resultEvent = startEvent ;
    startEvent = Event.checkEvent(event) ;
    return resultEvent ;
    }

    /**
    * Set event to notify when movement is done. May be null.
    *
    * @param event Event to notify when movement is done
    *
    * @returns prior event
    */
    public Event setNextEvent ( Event event ) {
    Event resultEvent = nextEvent ;
    nextEvent = Event.checkEvent(event) ;

    // Prime the pump if necessary
    if ( movementDone ()) {
    causeNextEvent () ;
    }

    return resultEvent ;
    }

    /**
    * Cause one time and next event.
    * Normally called by the matching multitasking object.
    */
    protected void causeNextEvent () {
    // Notify event that the next movement can be started
    nextEvent.notify ( this ) ;

    // Notify event that the next movement can be started
    oneTimeEvent.notify ( this ) ;
    oneTimeEvent = Event.nullEvent ;
    }

    /**
    * This method should be called at the beginning of a movement method.
    */
    protected void startMovement () {
    startEvent.notify (this) ;
    }

    /**
    * Check if movement is done. This should be called until it
    * returns true.
    *
    * @returns true if done waiting for movement
    */
    public abstract boolean movementDone () ;

    /**
    * Stop movement.
    */
    public void stop () {
    move ( 0 ) ;
    }

    /**
    * Set wheel speed to move forward/backward (negative).
    *
    * @param inches number of inches to move
    */
    public abstract void move ( int inches ) ;

    /**
    * Set wheel speed to pivot left (positive) or right (negative).
    *
    * @param steps number of steps to turn
    */
    public abstract void pivot ( int steps ) ;

    /**
    * Turn left (positive) or right (negative).
    *
    * @param steps number of steps to turn
    */
    public abstract void turn ( int steps ) ;
    }
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-07-23 22:10
    Go here

    http://www.parallax.com/javelin/javelinbot.asp

    It says:

    JavelinBot robot is a manuscript with Boe-Bot® robot projects designed for use the Javelin Stamp™ module. JavelinBot files (manuscript, program listings, and a revised stamp.util.os package (in the Javelin App Guide) are available for downloading below.

    regards peter
  • bxgirtenbxgirten Posts: 79
    edited 2005-07-23 23:43
    Thanks, Peter. I was about to embark on writing the missing class(es) so you saved me some time wink.gif

    -Bill
  • diafysaldiafysal Posts: 92
    edited 2005-07-24 22:40
    How come the "revised stamp.util.os package" are not on this site:
    http://www.parallax.com/javelin/doc/index.html
    ?

    Post Edited (diafysal) : 7/25/2005 10:21:52 PM GMT
  • PeckPeck Posts: 4
    edited 2006-10-05 06:47
    I too am having trouble using the classes in teh JBot package due to an incomplete Task or Event class. Do you think you can help me?

    Thanks in advance, Peck
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-10-05 16:47
    I attached a copy of the revised os.
    It also includes a class SimpleTask (and extended classes FlashLed, CheckPin, CheckPin_and_FlashLed)
    which are classes of my own that are much simpler than the Task class.

    regards peter
    zip
    29K
    os.zip 29.3K
Sign In or Register to comment.