com.flightpanels.scs
Class Receiver

java.lang.Object
  extended by com.flightpanels.scs.Receiver
All Implemented Interfaces:
ICanAeroDataManager

public class Receiver
extends java.lang.Object
implements ICanAeroDataManager

The main class and entry point to the CAN Aerospace world. It manages network access and handles all protocol requirements. The receiver maintains a list of CAN ids the application subscribed to. Notification on data changes is available either via callback functions or through pointers to variables that shall be updated. Calling Receiver::requestData enables you to communicate with all participants on the bus. It is the sole thing to do for interaction with the simulator. For more advanced use cases, like custom node services and publishing own data, inherit from Receiver and reimplement handleSTS, handleMCS and handleDRS functions. For even more customization, you can implement the CanAeroDataManager interface. Thread safety: This class is reentrant. Callbacks are guaranteed to be invoked from the same thread the Receiver::run() function is called.

Version:
1.2
Author:
(c) 2009, 2010 by Philipp Münzel, Technische Universität Darmstadt, Department of Mathematics

Method Summary
 boolean handleDRS(long id)
          Handle incoming data request services.
 void handleMCS(int module, int mode)
          Handle incoming module configuration services.
 void handleMIS()
          Handle incoming module information services.
 void handleSTS()
          Handle incoming state transmission services.
 void incomingData(can_t msg)
          Handle incoming data the application subscribed to.
 void requestData(long id, boolean id29, IUpdateable<java.lang.Boolean> update, java.lang.Boolean ref)
          Request to receive updates on the given CAN Id from the bus.
 void requestData(long id, boolean id29, IUpdateable<java.lang.Double> update, java.lang.Double ref)
          Request to receive updates on the given CAN Id from the bus.
 void requestData(long id, boolean id29, IUpdateable<java.lang.Float> update, java.lang.Float ref)
          Request to receive updates on the given CAN Id from the bus.
 void requestData(long id, boolean id29, IUpdateable<java.lang.Integer> update, java.lang.Integer ref)
          Request to receive updates on the given CAN Id from the bus.
 void requestData(long id, boolean id29, IUpdateable<java.lang.String> update, java.lang.String ref)
          Request to receive updates on the given CAN Id from the bus.
 void requestData(long id, boolean id29, IUpdateable<java.util.Vector<java.lang.Float>> update, java.util.Vector<java.lang.Float> ref)
          Request to receive updates on the given CAN Id from the bus.
 void run()
          Call this repeatedly, either from the application's main loop or a separate application thread.
 void sendData(long id, boolean id29, java.lang.Object value)
          Send value of given CAN id to the bus, so other participants are informed and can synchronize themselves to the new value.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

requestData

public void requestData(long id,
                        boolean id29,
                        IUpdateable<java.lang.Integer> update,
                        java.lang.Integer ref)
Request to receive updates on the given CAN Id from the bus. The identifier distribution defines which data format is used.

Parameters:
id - CAN id of simulation data, specified in identifier distribution
id29 - True for 29 bit, false for 11 bit CAN id
update - callback function you want to be called when value is updated
ref - dummy parameter to work around Java's stupid type-erasure.

requestData

public void requestData(long id,
                        boolean id29,
                        IUpdateable<java.lang.Float> update,
                        java.lang.Float ref)
Request to receive updates on the given CAN Id from the bus. The identifier distribution defines which data format is used.

Parameters:
id - CAN id of simulation data, specified in identifier distribution
id29 - True for 29 bit, false for 11 bit CAN id
update - callback function you want to be called when value is updated
ref - dummy parameter to work around Java's stupid type-erasure.

requestData

public void requestData(long id,
                        boolean id29,
                        IUpdateable<java.lang.Double> update,
                        java.lang.Double ref)
Request to receive updates on the given CAN Id from the bus. The identifier distribution defines which data format is used.

Parameters:
id - CAN id of simulation data, specified in identifier distribution
id29 - True for 29 bit, false for 11 bit CAN id
update - callback function you want to be called when value is updated
ref - dummy parameter to work around Java's stupid type-erasure.

requestData

public void requestData(long id,
                        boolean id29,
                        IUpdateable<java.lang.Boolean> update,
                        java.lang.Boolean ref)
Request to receive updates on the given CAN Id from the bus. The identifier distribution defines which data format is used.

Parameters:
id - CAN id of simulation data, specified in identifier distribution
id29 - True for 29 bit, false for 11 bit CAN id
update - callback function you want to be called when value is updated
ref - dummy parameter to work around Java's stupid type-erasure.

requestData

public void requestData(long id,
                        boolean id29,
                        IUpdateable<java.lang.String> update,
                        java.lang.String ref)
Request to receive updates on the given CAN Id from the bus. The identifier distribution defines which data format is used.

Parameters:
id - CAN id of simulation data, specified in identifier distribution
id29 - True for 29 bit, false for 11 bit CAN id
update - callback function you want to be called when value is updated
ref - dummy parameter to work around Java's stupid type-erasure.

requestData

public void requestData(long id,
                        boolean id29,
                        IUpdateable<java.util.Vector<java.lang.Float>> update,
                        java.util.Vector<java.lang.Float> ref)
Request to receive updates on the given CAN Id from the bus. The identifier distribution defines which data format is used.

Parameters:
id - CAN id of simulation data, specified in identifier distribution
id29 - True for 29 bit, false for 11 bit CAN id
update - callback function you want to be called when value is updated
ref - dummy parameter to work around Java's stupid type-erasure.

handleDRS

public boolean handleDRS(long id)
Handle incoming data request services. You may override this function if you inherit from Receiver. The data request service must only answer requests for CAN ids published exclusively by your application.

Specified by:
handleDRS in interface ICanAeroDataManager
Parameters:
id - CAN id of data to be transmitted (cyclic) from now on

handleMCS

public void handleMCS(int module,
                      int mode)
Handle incoming module configuration services. You may override this function if you inherit from Receiver.

Specified by:
handleMCS in interface ICanAeroDataManager
Parameters:
module - Module affected
mode - Mode parameter that shall be passed to this module

handleSTS

public void handleSTS()
Handle incoming state transmission services. You may override this function if you inherit from Receiver. The state transmission service must transmit all CAN ids published exclusively by your application once.

Specified by:
handleSTS in interface ICanAeroDataManager

handleMIS

public void handleMIS()
Handle incoming module information services. You may override this function if you inherit from Receiver.

Specified by:
handleMIS in interface ICanAeroDataManager

incomingData

public void incomingData(can_t msg)
Handle incoming data the application subscribed to. Is called on incoming normal operation data.

Specified by:
incomingData in interface ICanAeroDataManager
Parameters:
msg - Message containing normal operation data

sendData

public void sendData(long id,
                     boolean id29,
                     java.lang.Object value)
Send value of given CAN id to the bus, so other participants are informed and can synchronize themselves to the new value.

Parameters:
id - CAN id of simulation data, specified in identifier distribution
id29 - True for 29 bit, false for 11 bit CAN id
value - value to send to the bus Contrary to the C++ version, this is not type-safe and allows you to send malformed massages. You need to know what you are doing.

run

public void run()
Call this repeatedly, either from the application's main loop or a separate application thread. Will update pointers and invoke callbacks with new data. Big black magic box that makes all work as you expect, ensuring the protocol is handled following the CAN Aerospace and SCS specifications. It is guaranteed that all callbacks are called from the very same thread this function is called from.