Undo: auto-formating

parent 575485a7
......@@ -2,8 +2,8 @@
#include "${compName}.h"
class IAdapter_${compName}{
public:
virtual ~IAdapter_${compName}(){}
virtual void init(${compName}* comp) = 0;
virtual void tick() = 0;
public:
virtual ~IAdapter_${compName}(){}
virtual void init(${compName}* comp) = 0;
virtual void tick() = 0;
};
#include
<iostream>
#include
<thread>
#include
<chrono>
#include
<atomic>
#include
<list>
#include "IAdapter_${compName}.h"
#include <iostream>
#include <thread>
#include <chrono>
#include <atomic>
#include <list>
#include "IAdapter_${compName}.h"
${includes}
using namespace std;
using namespace chrono;
${includes}
static int exeMs = 100;
using namespace std;
using namespace chrono;
bool parseCommandLineParameters(int argc, char* argv[]){
if(argc == 1){
return true;
}
if(argc == 3 && string(argv[1]) == "-t"){
try{
int tmp = stoi(argv[2]);
if(tmp >= 0){
exeMs = tmp;
return true;
}
}catch(...){
//Ignore
}
}
cout << "Usage: " << argv[0] << " [-h | -t sleepTimeMs]\n";
return false;
}
static int exeMs = 100;
void startMiddleware(IAdapter_${compName}& adapter,${compName}& comp,atomic
<bool>& done){
adapter.init(&comp);
done = true;
}
bool parseCommandLineParameters(int argc, char* argv[]){
if(argc == 1){
return true;
}
if(argc == 3 && string(argv[1]) == "-t"){
try{
int tmp = stoi(argv[2]);
if(tmp >= 0){
exeMs = tmp;
return true;
}
}catch(...){
//Ignore
}
}
cout << "Usage: " << argv[0] << " [-h | -t sleepTimeMs]\\n";
return false;
}
int main(int argc, char* argv[])
{
if(!parseCommandLineParameters(argc,argv)){
return 1;
}
void startMiddleware(IAdapter_${compName}& adapter,${compName}& comp,atomic<bool>& done){
adapter.init(&comp);
done = true;
}
atomic
<bool> done(false);
${compName} comp;
comp.init();
int main(int argc, char* argv[])
{
if(!parseCommandLineParameters(argc,argv)){
return 1;
}
list
<IAdapter_${compName}
*> adapters;
${addAdapters}
list
<thread
*> threads;
for(auto a : adapters){
threads.push_back(new thread(startMiddleware,ref(*a),ref(comp),ref(done)));
}
atomic<bool> done(false);
${compName} comp;
comp.init();
cout << "waiting for all middleware to start\n";
this_thread::sleep_for(seconds(3));
cout << "started! Executing every " << exeMs << "ms\n";
list<IAdapter_${compName}*> adapters;
${addAdapters}
time_point
<system_clock> start, end;
while(!done){
start = system_clock::now();
list<thread*> threads;
for(auto a : adapters){
threads.push_back(new thread(startMiddleware,ref(*a),ref(comp),ref(done)));
}
comp.execute();
for(auto a : adapters){
(*a).tick();
}
cout << "waiting for all middleware to start\\n";
this_thread::sleep_for(seconds(3));
cout << "started! Executing every " << exeMs << "ms\\n";
end = system_clock::now();
int elapsedMs = duration_cast
<milliseconds>(end-start).count();
int newSleep = exeMs - elapsedMs;
if(newSleep <= 0){
cout << "Cant keep up! "<< (-newSleep) <<"ms late!\n";
}else{
this_thread::sleep_for(milliseconds(newSleep));
}
}
time_point<system_clock> start, end;
while(!done){
start = system_clock::now();
return 0;
}
\ No newline at end of file
comp.execute();
for(auto a : adapters){
(*a).tick();
}
end = system_clock::now();
int elapsedMs = duration_cast<milliseconds>(end-start).count();
int newSleep = exeMs - elapsedMs;
if(newSleep <= 0){
cout << "Cant keep up! "<< (-newSleep) <<"ms late!\\n";
}else{
this_thread::sleep_for(milliseconds(newSleep));
}
}
return 0;
}
\ No newline at end of file
#pragma once
#include "${compName}.h"
#include
<thread>
#include
<chrono>
#include "IAdapter_${compName}.h"
#include <thread>
#include <chrono>
#include "IAdapter_${compName}.h"
class DummyAdapter_${compName}: public IAdapter_${compName}{
${compName}* component;
class DummyAdapter_${compName}: public IAdapter_${compName}{
${compName}* component;
public:
DummyAdapter_${compName}(){
public:
DummyAdapter_${compName}(){
}
}
void tick(){
cout << "Dummy publish data: component.out1 = "<< component->out1 << endl;
}
void tick(){
cout << "Dummy publish data: component.out1 = "<< component->out1 << endl;
}
void init(${compName}* comp){
this->component = comp;
while(1){
std::this_thread::sleep_for(std::chrono::seconds(1));
component->in2 += 1000;
}
}
void init(${compName}* comp){
this->component = comp;
while(1){
std::this_thread::sleep_for(std::chrono::seconds(1));
component->in2 += 1000;
}
}
};
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment