The Robot Application Programming Interface Delegate Project
|
/* * 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.RapidAssetState; import gov.nasa.rapid.utils.RapidMessageUtils; public class RapidAssetConfigurationModel extends RapidExampleModel { public static final String ID = "gov.nasa.rapid.examples.models.RapidAssetConfigurationModel"; public RapidAssetConfigurationModel() { this(DDSExampleSettings.CLIENT_AGENT); } public RapidAssetConfigurationModel(Agent agent) { super(agent); setModelName("RapidAssetConfigurationModel"); registerForMessage(RapidMessageUtils.getAvailablePartitionsForSubscribing(), MessageType.ASSET_STATE_TYPE, new IRapidEventListener() { public void rapidEventReceived(Agent agent, MessageType type, IRapidMessage msg) { RapidAssetState state = null; if (msg instanceof RapidAssetState) state = (RapidAssetState)msg; if (state == null) return; System.err.println("\n\n\n---- RapidAssetConfigurationModel: " + state + "\n\n\n\n"); setModelName("RapidAssetConfigurationModel"); setMessage(state.toString()); setTimeStamp(state.getHeader().timeStamp); updateModelChangedListeners(); } }); } }