@@ -236,6 +236,31 @@ void master402_post_emcy(CO_Data* d, UNS8 nodeID, UNS16 errCode, UNS8 errReg, co
236236 }
237237}
238238/*******************************ERROR FIX CODE*****************************************************************/
239+ /**
240+ * @brief 主站恢复操作状态.
241+ * @param None.
242+ * @retval None.
243+ * @note 重新开始生产者心跳
244+ */
245+ void master_resume_start (CO_Data * d ,UNS8 nodeId )
246+ {
247+ if (getState (d ) == Stopped )//can通信异常,发送失败多次,进入停止状态
248+ {
249+ //Stop状态时会删除生产者心跳定时器
250+ if (* d -> ProducerHeartBeatTime )//恢复到OP状态时检查是否有生产者心跳时间
251+ {
252+ TIMEVAL time = * d -> ProducerHeartBeatTime ;
253+ extern void ProducerHeartbeatAlarm (CO_Data * d , UNS32 id );
254+ //设置生产者时间定时器,并设置定时回调
255+ LOG_W ("Restart the producer heartbeat" );
256+ d -> ProducerHeartBeatTimer = SetAlarm (d , 0 , & ProducerHeartbeatAlarm , MS_TO_TIMEVAL (time ), MS_TO_TIMEVAL (time ));
257+ }
258+ LOG_W ("The master station enters the operation state from the stop state" );
259+ setState (d , Operational );//转入Operational状态
260+ }
261+ masterSendNMTstateChange (d ,nodeId ,NMT_Start_Node );
262+ }
263+
239264/**
240265 * @brief 修复节点NMT异常
241266 * @param None.
@@ -265,21 +290,7 @@ static void master402_fix_node_Disconnected(void* parameter)
265290 }
266291 else if (now == Pre_operational )
267292 {
268- if (getState (OD_Data ) == Stopped )//can通信异常,发送失败多次,进入停止状态
269- {
270- //Stop状态时会删除生产者心跳定时器
271- if (* OD_Data -> ProducerHeartBeatTime )//恢复到OP状态时检查是否有生产者心跳时间
272- {
273- TIMEVAL time = * OD_Data -> ProducerHeartBeatTime ;
274- extern void ProducerHeartbeatAlarm (CO_Data * d , UNS32 id );
275- //设置生产者时间定时器,并设置定时回调
276- LOG_W ("Restart the producer heartbeat" );
277- OD_Data -> ProducerHeartBeatTimer = SetAlarm (OD_Data , 0 , & ProducerHeartbeatAlarm , MS_TO_TIMEVAL (time ), MS_TO_TIMEVAL (time ));
278- }
279- LOG_W ("The master station enters the operation state from the stop state" );
280- setState (OD_Data , Operational );//转入Operational状态
281- }
282- masterSendNMTstateChange (OD_Data ,heartbeatID ,NMT_Start_Node );
293+ master_resume_start (OD_Data ,heartbeatID );
283294 LOG_I ("nodeID:%d,Determines that the line is restored and switches the slave machine to operation mode, deleting the current thread" ,heartbeatID );
284295 node [heartbeatID - 2 ].lock = 0 ;
285296 return ;//退出线程
0 commit comments