- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

# canaerobusconnector.h

    00001 // Copyright (C) 2008,2009,2010 by Philipp Münzel. All rights reserved.
    00002 // Released under the terms of the license described in license.txt
    00003
    00004 #ifndef CANAEROBUSCONNECTOR_H
    00005 #define CANAEROBUSCONNECTOR_H
    00006
    00007 #include "dllexport.h"
    00008
    00009 #include <memory>
    00010 #include <queue>
    00011 #include <string>
    00012 #include <boost/date_time.hpp>
    00013
    00014 #include "canaerotypes.h"
    00015 #include "connectedclient.h"
    00016 #include "connector.h"
    00017 #include "scopedlock.h"
    00018 #include "nodesmodulemanager.h"
    00019
    00020 namespace SCS {
    00021
    00022 class CanAeroDataManager;
    00023
    00035 class DLL_PUBLIC CanAeroBusConnector: public BusConnector<can_t>
    00036 {
    00037 public:
    00038
    00045     CanAeroBusConnector(CanAeroDataManager* manager,
    00046                         NetworkConnector<can_t>* connector,
    00047                         uint8_t own_node_id,
    00048                         uint8_t config_revision);
    00049
    00053     void doHouseKeeping();
    00054
    00058     uint8_t ownNodeId() const;
    00059
    00063     void send(const can_t& msg);
    00064
    00068     void send(const std::vector<can_t>& msg);
    00069
    00074     void sendSTS(uint8_t node_id = BROADCAST_NODE_ID);
    00075
    00082     void sendDRS(can_Id_t can_id, uint8_t node_id = BROADCAST_NODE_ID);
    00083
    00088     void sendIDS(uint8_t node_id = BROADCAST_NODE_ID);
    00089
    00095     void receiveMessage(const can_t& msg);
    00096
    00102     void receiveMessage(const std::vector<can_t>& msg);
    00103
    00107     void requestModule(uint8_t node_id, uint16_t module, uint16_t mode);
    00108
    00114     bool isModuleActive(uint8_t node_id, uint16_t module);
    00115
    00120     bool isClientActive(uint8_t node_id);
    00121
    00122 private:
    00123
    00128     void sendMIS(uint8_t node_id = BROADCAST_NODE_ID);
    00129
    00130     void processServiceRequests(const can_t&);
    00131
    00132     void processServiceResponses(const can_t&);
    00133
    00134     uint8_t getNewNodeId(uint32_t uuid);
    00135
    00136
    00137 private:
    00138
    00139     typedef std::map<uint8_t, ConnectedClient> ClientMap;
    00140     typedef std::map<uint32_t, uint8_t> NCSMap;
    00141     Mutex m_map_mutex;
    00142     ClientMap m_connected_clients;
    00143     NCSMap m_ncs_lookup;
    00144     uint8_t m_own_node_id;
    00145     const uint8_t m_config_revision;
    00146     uint32_t m_gen_uuid;
    00147     CanAeroDataManager* m_manager;
    00148     NetworkConnector<can_t>* m_network_connector;
    00149     NodesModuleManager m_nodes_module_manager;
    00150     boost::posix_time::ptime m_last_did_MIS;
    00151 #ifdef USE_STOCK_DATAFRAME
    00152     uint32_t m_frame_counter;
    00153 #endif
    00154 };
    00155
    00156 }
    00157
    00158 #endif // CANAEROBUSCONNECTOR_H