You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							30 lines
						
					
					
						
							816 B
						
					
					
				
			
		
		
	
	
							30 lines
						
					
					
						
							816 B
						
					
					
				| #include "stdafx.h"
 | |
| #include "MessagePeriodic.h"
 | |
| #include "J2534Connection.h"
 | |
| 
 | |
| MessagePeriodic::MessagePeriodic(
 | |
| 	std::chrono::microseconds delay,
 | |
| 	std::shared_ptr<MessageTx> msg
 | |
| ) : Action(msg->connection, delay), msg(msg), runyet(FALSE), active(TRUE) { };
 | |
| 
 | |
| void MessagePeriodic::execute() {
 | |
| 	if (!this->active) return;
 | |
| 	if (this->runyet) {
 | |
| 		if (msg->isFinished()) {
 | |
| 			msg->reset();
 | |
| 			msg->execute();
 | |
| 		}
 | |
| 	} else {
 | |
| 		this->runyet = TRUE;
 | |
| 		msg->execute();
 | |
| 	}
 | |
| 
 | |
| 	if (auto conn_sp = this->connection.lock()) {
 | |
| 		if (auto panda_dev_sp = conn_sp->getPandaDev()) {
 | |
| 			//Scheduling must be relative to now incase there was a long stall that
 | |
| 			//would case it to be super far behind and try to catch up forever.
 | |
| 			this->scheduleImmediateDelay();
 | |
| 			panda_dev_sp->insertActionIntoTaskList(shared_from_this());
 | |
| 		}
 | |
| 	}
 | |
| }
 | |
| 
 |