23 data.node_id = node_id;
31 :
Layer(
"Node 301"), node_id_(node_id), interface_(interface), sync_(sync) , state_(Unknown), sdo_(interface, dict, node_id), pdo_(interface){
35 catch(
const std::out_of_range){
40 boost::timed_mutex::scoped_lock lock(
mutex);
45 boost::timed_mutex::scoped_lock lock(
mutex);
56 boost::timed_mutex::scoped_lock lock(
mutex);
69 boost::timed_mutex::scoped_lock lock(
mutex);
77 boost::timed_mutex::scoped_lock lock(
mutex);
85 boost::timed_mutex::scoped_lock lock(
mutex);
95 bool changed =
state_ != s;
116 boost::mutex::scoped_lock cond_lock(
cond_mutex);
119 assert(msg.
dlc == 1);
123 boost::mutex::scoped_lock cond_lock(
cond_mutex);
127 if(
cond.wait_until(cond_lock,abs_time) == boost::cv_status::timeout)
143 boost::mutex::scoped_lock cond_lock(
cond_mutex);
149 if(current_state >
Init){
151 status.
error(
"heartbeat problem");
153 status.
error(
"not operational");
160 if(current_state >
Init){
170 report.
error(
"Mode not operational");
171 report.
add(
"Node state", (
int)state);
173 report.
error(
"Heartbeat timeout");
184 status.
error(boost::str(boost::format(
"could not reset node '%1%'") % (
int)
node_id_));
199 status.
error(boost::str(boost::format(
"could not start node '%1%'") % (
int)
node_id_));
207 status.
error(boost::str(boost::format(
"could not start node '%1%'") % (
int)
node_id_));
bool init(const ObjectStorageSharedPtr storage, LayerStatus &status)
boost::shared_ptr< SyncCounter > SyncCounterSharedPtr
ObjectStorage::Entry< ObjectStorage::DataType< ObjectDict::DEFTYPE_UNSIGNED16 >::type > heartbeat_
void switchState(const uint8_t &s)
Frame(uint8_t node_id, const Command &c)
void handleNMT(const can::Frame &msg)
const can::CommInterfaceSharedPtr interface_
virtual void handleInit(LayerStatus &status)
virtual void handleDiag(LayerReport &report)
boost::atomic< LayerState > state
boost::array< value_type, 8 > data
boost::shared_ptr< CommInterface > CommInterfaceSharedPtr
int wait_for(const State &s, const T &timeout)
boost::chrono::high_resolution_clock::time_point time_point
const SyncCounterSharedPtr sync_
virtual void handleShutdown(LayerStatus &status)
void read(LayerStatus &status)
ObjectDict::ObjectDictSharedPtr ObjectDictSharedPtr
const ObjectStorageSharedPtr getStorage()
virtual void handleWrite(LayerStatus &status, const LayerState ¤t_state)
boost::chrono::high_resolution_clock::time_point heartbeat_timeout_
uint16_t getHeartbeatInterval()
can::FrameListenerConstSharedPtr nmt_listener_
Node(const can::CommInterfaceSharedPtr interface, const ObjectDictSharedPtr dict, uint8_t node_id, const SyncCounterSharedPtr sync=SyncCounterSharedPtr())
virtual void handleRecover(LayerStatus &status)
void setHeartbeatInterval()
void add(const std::string &key, const T &value)
virtual void handleRead(LayerStatus &status, const LayerState ¤t_state)
boost::condition_variable cond
const void error(const std::string &r)
time_point get_abs_time(const time_duration &timeout)
virtual void handleHalt(LayerStatus &status)
can::SimpleDispatcher< StateListener > state_dispatcher_