Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromefavrou authored Aug 31, 2018
1 parent de1deec commit 2a0ba15
Show file tree
Hide file tree
Showing 5 changed files with 373 additions and 41 deletions.
206 changes: 169 additions & 37 deletions Intervallometre.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
#include <sstream>
#include <chrono>
#include <thread>
#include <algorithm>

#include "Remote_controle_apn.hpp"

class Intervallometre
{
Expand All @@ -19,13 +22,17 @@ class Intervallometre
bool wait:1;

int frame;
int intervalle;
int delay;
int iso;
float intervalle;
float delay;
std::string iso;
int exposure;
int aperture;
int target;
int format;
std::string aperture;
std::string target;
std::string format;
std::string shutter;
std::string effect;
std::string wb;

};

Intervallometre(void)
Expand Down Expand Up @@ -56,6 +63,8 @@ class Intervallometre
std::cout << instruction <<std::endl;
continue;
}
if(instruction[0]=='#')
continue;
}

std::stringstream ss_buf;
Expand Down Expand Up @@ -85,84 +94,207 @@ class Intervallometre
return false;
}

void run_seq(void)
void run_seq(RC_Apn & apn)
{
if(this->debug_mode)
std::cout << " La sequance commance" <<std::endl;
std::cout << " La sequance commance" <<std::endl<<std::endl;
for(auto & seq:this->m_seq)
{
if(seq.user_local)
{
if(seq.wait)
{
std::cin.clear();
std::cout << "Appuis sur Enter requis" << std::endl;
std::cout <<std::endl << "Appuis sur Enter requis" << std::endl<< std::endl;
std::cin.get();
}

if(seq.delay>0)
{
std::cout << "Attendre " << seq.delay <<" s"<<std::endl;
std::this_thread::sleep_for(std::chrono::duration<int, std::milli>(seq.delay*1000));
std::cout<<std::endl << "Attendre " << seq.delay <<" s"<<std::endl<<std::endl;
std::this_thread::sleep_for(std::chrono::duration<float, std::milli>(seq.delay*1000));
}

}
else
{
for(auto i=0;i<seq.frame;i++)
{
std::cout << "frame "<<i+1<<"/"<<seq.frame<<std:: endl;
std::cout <<std::endl<< "frame "<<i+1<<"/"<<seq.frame<<std:: endl;

if(apn.check_apn())
{
std::cout <<"ne pas débrancher apn capture en cour iso: " << seq.iso << " exposition: "<<seq.exposure<<" ouverture: " <<seq.aperture <<std::endl;

std::stringstream ss_t;
ss_t << seq.exposure-1;
std::string expo;
ss_t >>expo;


ss_t.clear();
ss_t << seq.intervalle;
std::string inter;
ss_t >>inter;

apn.capture_new_EOS_DSLR(inter,seq.iso,expo,seq.aperture,"1","9","bulb","0","4");
}
else
{
std::cout << "capture annulée aucun apn detecté" << std::endl;
}
}
}

}
}

size_t size(void)const noexcept
{
return this->m_seq.size();
}

bool check_sequance(RC_Apn & apn)
{
bool check(true);
int line(0);
for(auto & i: this->m_seq)
{
line++;

std::stringstream ss_buff;
std::string val;

if(i.aperture!="-1")
{
ss_buff <<i.aperture;
ss_buff >>val;
if(check)
check=this->check_cmd(apn,RC_Apn::Parameter::APERTURE,line,val);
else
this->check_cmd(apn,RC_Apn::Parameter::APERTURE,line,val);
}

if(i.shutter!="-1")
{
ss_buff.clear();
ss_buff <<i.shutter;
ss_buff >>val;
if(check)
check=this->check_cmd(apn,RC_Apn::Parameter::SHUTTERSPEED,line,val);
else
this->check_cmd(apn,RC_Apn::Parameter::SHUTTERSPEED,line,val);
}

if(i.wb!="-1")
{
ss_buff.clear();
ss_buff <<i.wb;
ss_buff >>val;
if(check)
check=this->check_cmd(apn,RC_Apn::Parameter::WHITE_BALANCE,line,val);
else
this->check_cmd(apn,RC_Apn::Parameter::WHITE_BALANCE,line,val);
}

if(i.effect!="-1")
{
ss_buff.clear();
ss_buff <<i.effect;
ss_buff >>val;
if(check)
check=this->check_cmd(apn,RC_Apn::Parameter::PICTURE_STYLE,line,val);
else
this->check_cmd(apn,RC_Apn::Parameter::PICTURE_STYLE,line,val);
}


if(i.iso!="-1")
{
ss_buff.clear();
ss_buff <<i.iso;
ss_buff >>val;
if(check)
check=this->check_cmd(apn,RC_Apn::Parameter::ISO,line,val);
else
this->check_cmd(apn,RC_Apn::Parameter::ISO,line,val);
}

if(i.delay<=0 && i.delay!=-1)
std::cerr << "ligne " << line << " erreur pour wait"<<i.delay<<" non pris en charge (<=0)"<<std::endl;

if(i.frame<=0 && i.frame!=-1)
std::cerr << "ligne " << line << " erreur pour wait"<<i.delay<<" non pris en charge (<=0)"<<std::endl;

if(i.intervalle<1 && i.intervalle!=-1)
std::cerr << "ligne " << line << " erreur pour wait"<<i.delay<<" non pris en charge (< 1)"<<std::endl;

}

return check;
}

void help(void)
{

}

private:
Sequance interpreter(std::stringstream & ss_buffer)
{
Sequance seq;
seq.wait=false;
seq.delay=0;
seq.delay=-1;
seq.frame=-1;
seq.intervalle=-1;
seq.iso="-1";
seq.aperture="-1";
seq.exposure=-1;
seq.shutter="-1";
seq.effect="-1";
seq.wb="-1";

std::string cmd;

while(ss_buffer)
{
ss_buffer >> cmd;

if(cmd=="LOC")
seq.user_local=true;
else if(cmd=="GP2")
seq.user_local=false;
else if(cmd=="WAIT")
seq.wait=true;
else if(cmd=="DELAY")
ss_buffer >> seq.delay;
else if(cmd=="FRAME")
ss_buffer >> seq.frame;
else if(cmd=="INTER")
ss_buffer >> seq.intervalle;
else if(cmd=="ISO")
ss_buffer >> seq.iso;
else if(cmd=="EXPO")
ss_buffer >> seq.exposure;
else if(cmd=="APER")
ss_buffer >> seq.aperture;
else if(cmd=="TARGET")
ss_buffer >> seq.target;
else if(cmd=="FORMAT")
ss_buffer >> seq.format;
if(cmd=="LOC") seq.user_local=true;
else if(cmd=="GP2") seq.user_local=false;
else if(cmd=="WAIT") seq.wait=true;
else if(cmd=="DELAY") ss_buffer >> seq.delay;
else if(cmd=="FRAME") ss_buffer >> seq.frame;
else if(cmd=="INTER") ss_buffer >> seq.intervalle;
else if(cmd=="ISO") ss_buffer >> seq.iso;
else if(cmd=="EXPO") ss_buffer >> seq.exposure;
else if(cmd=="APER") ss_buffer >> seq.aperture;
else if(cmd=="TARGET") ss_buffer >> seq.target;
else if(cmd=="FORMAT") ss_buffer >> seq.format;
else if(cmd=="SHUTTER") ss_buffer >> seq.shutter;
else if(cmd=="EFFECT") ss_buffer >> seq.effect;
else if(cmd=="WB") ss_buffer >> seq.wb;
}

return seq;
}

bool check_cmd(RC_Apn & apn,RC_Apn::Parameter const & param,int line,std::string value)
{
auto v= apn.get_parameter(param);

auto res= std::find(v.begin(),v.end(),value);

if(res == v.end())
{
std::cerr << "ligne " << line << " erreur pour " << RC_Apn::parameter_to_string(param) <<" "<<value<<" non pris en charge"<<std::endl;

return false;
}
else if(this->debug_mode)
std::cout << "commande checker avec succes" <<std::endl;

return true;
}

std::vector<Sequance> m_seq;
};

Expand Down
Loading

0 comments on commit 2a0ba15

Please sign in to comment.