The Robot Application Programming Interface Delegate Project
RAPID Logo

RapidArticulationExampleModel.java

/*
 * Copyright (c) 2009 United States Government as represented by the
 * Administrator of the National Aeronautics and Space Administration.
 * All Rights Reserved.
 */

package gov.nasa.rapid.examples.models;

import gov.nasa.rapid.dds.Agent;
import gov.nasa.rapid.event.IRapidEventListener;
import gov.nasa.rapid.examples.DDSExampleSettings;
import gov.nasa.rapid.message.IRapidMessage;
import gov.nasa.rapid.message.MessageType;
import gov.nasa.rapid.message.RapidJointSample;

public class RapidArticulationExampleModel extends RapidExampleModel {

    public static final String ID = "gov.nasa.rapid.examples.models.RapidArticulationModel";

    public RapidArticulationExampleModel() {
        this(DDSExampleSettings.CLIENT_AGENT);
    }

    public RapidArticulationExampleModel(Agent agent) {
        super(agent);

        setModelName("RapidArticulationModel");

        registerForMessage(Agent.GenericSim, MessageType.JOINT_SAMPLE_TYPE, new IRapidEventListener() {

            public void rapidEventReceived(Agent agent, MessageType type, IRapidMessage msg) {
                RapidJointSample art = null;

                if (msg instanceof RapidJointSample)
                    art = (RapidJointSample)msg;

                if (art == null) return;

                System.err.println("\n\n\n---- RapidArticulationModel: " + msg + "\n\n\n\n");
                setModelName("RapidArticulationModel");
                setMessage(art.toString());
                setTimeStamp(art.getHeader().timeStamp);

                updateModelChangedListeners();
            }
        });
    }
}

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines