diff --git a/drivers/CMakeLists.txt b/drivers/CMakeLists.txt index f4d52ca..ca82738 100644 --- a/drivers/CMakeLists.txt +++ b/drivers/CMakeLists.txt @@ -14,12 +14,12 @@ set(dummy_src_files dummy/temperature_dummy.cpp ) -set(Eurotherm_src_files +#set(Eurotherm_src_files # Eurotherm-2000Series/control.cpp - Eurotherm-2000Series/Eurotherm-2000Series.cpp +# Eurotherm-2000Series/Eurotherm-2000Series.cpp # Eurotherm-2000Series/gnuplot_output.cpp # Eurotherm-2000Series/test.cpp -) +#) set(PTS_src_files PTS-Synthesizer/PTS.cpp @@ -73,13 +73,16 @@ set(tiepie_src_files include_directories(..) # https://cmake.org/Wiki/CMake/Tutorials/Object_Library add_library(AD5791 STATIC ${AD5791_src_files}) +add_library(tempcont tempcont.cpp) #add_library(Datel STATIC ${Datel_src_files}) add_library(dummy STATIC ${dummy_src_files}) -add_library(Eurotherm-2000Series STATIC ${Eurotherm_src_files} tempcont.cpp) -add_library(PTS STATIC ${PTS_src_files}) -add_library(Spectrum_M2i40xxSeries STATIC ${M2i40xx_src_files}) +add_subdirectory(Eurotherm-2000Series) +add_subdirectory(PTS-Synthesizer) +add_subdirectory(Spectrum-M2i40xxSeries) +#add_library(Spectrum_M2i40xxSeries STATIC ${M2i40xx_src_files}) add_library(Spectrum_MI40xxSeries STATIC ${MI40xx_src_files}) add_subdirectory(SpinCore-PulseBlaster) + #add_library(PB STATIC ${general_src_files} SpinCore-PulseBlaster/SpinCore-PulseBlaster.cpp) #add_library(PB_PROG STATIC ${general_src_files} SpinCore-PulseBlaster/PulseBlasterProgram.cpp) add_library(PB24 STATIC ${PB24_src_files}) diff --git a/drivers/DAC-AD5791/AD5791.cpp b/drivers/DAC-AD5791/AD5791.cpp index f485edc..787dd9b 100644 --- a/drivers/DAC-AD5791/AD5791.cpp +++ b/drivers/DAC-AD5791/AD5791.cpp @@ -67,16 +67,15 @@ AD5791::AD5791(int myid) : id(myid) { } AD5791::~AD5791() {} - // This sets the dac_value void AD5791::set_dac(signed dw) { dac_value = dw; } -void AD5791::set_latch_bit(int le_bit) { +void AD5791::set_latch_bit(int le_bit) +{ latch_bit = le_bit; } - // This sets the DAC void AD5791::set_dac(state &experiment) { state_sequent *exp_sequence = dynamic_cast(&experiment); @@ -85,9 +84,10 @@ void AD5791::set_dac(state &experiment) { throw pfg_exception("cannot work on a single state, sorry (todo: change interface)"); else { for (state_sequent::iterator child_state = exp_sequence->begin(); - child_state != exp_sequence->end(); ++child_state) + child_state != exp_sequence->end(); ++child_state) { set_dac_recursive(*exp_sequence, child_state); -// std::cout << "first state"<< std::endl; + } + std::cout << "first state"<< std::endl; // Set DAC to 0 at start of experiment set_dac_to_zero(exp_sequence, exp_sequence->begin()); @@ -98,35 +98,51 @@ void AD5791::set_dac(state &experiment) { } } -void AD5791::set_dac_to_zero(state_sequent *exp_sequence, state::iterator where) { +state_sequent* AD5791::tx_bit(unsigned int bit) { + state_sequent* tx = new state_sequent(); + ttlout* ttl_state = new ttlout(); + state s(TIMING); + s.push_back(ttl_state); + + ttl_state->ttls = bit*(1<push_back(s.copy_new()); + ttl_state->ttls = (1<push_back(s.copy_new()); + return tx; +} + +void AD5791::set_dac_to_zero(state_sequent* exp_sequence, state::iterator where) { // 0001 0000 0000 0000 0000 0000 state s(TIMING); - ttlout *ttl_state = new ttlout(); + ttlout* ttl_state = new ttlout(); ttl_state->id = 0; s.push_front(ttl_state); - state_sequent *rep_sequence = new state_sequent(); + + // test exp_sequence->insert(where, tx_bit(1)); + exp_sequence->insert(where, tx_bit(1)); // 0 ttl_state->ttls = 0 + (1 << CLK_BIT); - rep_sequence->push_back(s.copy_new()); + exp_sequence->insert(where, s.copy_new()); ttl_state->ttls = 0; - rep_sequence->push_back(s.copy_new()); + exp_sequence->insert(where, s.copy_new()); // 0 ttl_state->ttls = 0 + (1 << CLK_BIT); - rep_sequence->push_back(s.copy_new()); + exp_sequence->insert(where, s.copy_new()); ttl_state->ttls = 0; - rep_sequence->push_back(s.copy_new()); + exp_sequence->insert(where, s.copy_new()); // 0 ttl_state->ttls = 0 + (1 << CLK_BIT); - rep_sequence->push_back(s.copy_new()); + exp_sequence->insert(where, s.copy_new()); ttl_state->ttls = 0; - rep_sequence->push_back(s.copy_new()); + exp_sequence->insert(where, s.copy_new()); // 1 ttl_state->ttls = (1<push_back(s.copy_new()); + exp_sequence->insert(where, s.copy_new()); ttl_state->ttls = (1<push_back(s.copy_new()); + exp_sequence->insert(where, s.copy_new()); // the rest + state_sequent *rep_sequence = new state_sequent(); rep_sequence->repeat = DAC_DATA_BITS; ttl_state->ttls = 0 + (1 << CLK_BIT); rep_sequence->push_back(s.copy_new()); @@ -145,30 +161,30 @@ void AD5791::init_dac(state_sequent *exp_sequence, state::iterator where) { ttlout *ttl_state = new ttlout(); ttl_state->id = 0; s.push_front(ttl_state); - state_sequent *rep_sequence = new state_sequent(); // 0010 0000 0000 0000 0000 0000 // 0 ttl_state->ttls = 0 + (1 << CLK_BIT); - rep_sequence->push_back(s.copy_new()); + exp_sequence->insert(where, s.copy_new()); ttl_state->ttls = 0; - rep_sequence->push_back(s.copy_new()); + exp_sequence->insert(where,s.copy_new()); // 0 ttl_state->ttls = 0 + (1 << CLK_BIT); - rep_sequence->push_back(s.copy_new()); + exp_sequence->insert(where, s.copy_new()); ttl_state->ttls = 0; - rep_sequence->push_back(s.copy_new()); + exp_sequence->insert(where, s.copy_new()); // 1 ttl_state->ttls = (1<push_back(s.copy_new()); + exp_sequence->insert(where,s.copy_new()); ttl_state->ttls = (1<push_back(s.copy_new()); + exp_sequence->insert(where,s.copy_new()); // 0 ttl_state->ttls = 0 + (1 << CLK_BIT); - rep_sequence->push_back(s.copy_new()); + exp_sequence->insert(where, s.copy_new()); ttl_state->ttls = 0; - rep_sequence->push_back(s.copy_new()); + exp_sequence->insert(where,s.copy_new()); // the rest + state_sequent *rep_sequence = new state_sequent(); rep_sequence->repeat = DAC_DATA_BITS; ttl_state->ttls = 0 + (1 << CLK_BIT); rep_sequence->push_back(s.copy_new()); @@ -179,7 +195,8 @@ void AD5791::init_dac(state_sequent *exp_sequence, state::iterator where) { //read in the word ttl_state->ttls = 0; exp_sequence->insert(where, s.copy_new()); - ttl_state->ttls = (1 << latch_bit); + ttl_state->ttls = (1 << latch_bit) + (1<insert(where, s.copy_new()); } @@ -204,7 +221,9 @@ void AD5791::set_dac_recursive(state_sequent &the_sequence, state::iterator &the // find an analogout section with suitable id state::iterator pos = this_state->begin(); while (pos != this_state->end()) { // state members loop - analogout *aout = dynamic_cast(*pos); // initialize new analogout + analogout *aout = dynamic_cast(*pos); // initialize new analogout from state + if (aout != NULL) + std::cout << aout->id << std::endl; // This is for me, analogout is != NULL (there is an analogout) and has my ID if (aout != NULL && aout->id == id) { if (dac_analog_out == NULL) { @@ -219,16 +238,17 @@ void AD5791::set_dac_recursive(state_sequent &the_sequence, state::iterator &the // remove the analog out section this_state->erase(pos++); } else { + std::cout << "nope" << std::endl; ++pos; } } // state members loop - if (dac_analog_out != NULL) { // state modifications + //std::cout<<"found a analog out section, value="<dac_value<length < TIMING * (DAC_CONTROL_BITS + DAC_DATA_BITS) * 2 + 1) - throw pfg_exception("time is too short to save DAC information"); + throw pfg_exception("AD5791: time is too short to save DAC information"); else { // copy of original state state *register_state = new state(*this_state); @@ -249,6 +269,7 @@ void AD5791::set_dac_recursive(state_sequent &the_sequence, state::iterator &the int bit = dac_analog_out->dac_value & 1; dac_word.push_back(bit); dac_analog_out->dac_value >>= 1; + std::cout << bit; } // reverse the bit pattern (MSB first) reverse(dac_word.begin(), dac_word.end()); diff --git a/drivers/DAC-AD5791/AD5791.h b/drivers/DAC-AD5791/AD5791.h index c243d23..f562790 100644 --- a/drivers/DAC-AD5791/AD5791.h +++ b/drivers/DAC-AD5791/AD5791.h @@ -6,6 +6,7 @@ #include "core/states.h" #include "drivers/pfggen.h" +#include "../../core/states.h" /** * \ingroup drivers @@ -39,6 +40,8 @@ public: void set_dac_to_zero(state_sequent* exp_sequence, state::iterator where); void init_dac(state_sequent* exp_sequence, state::iterator where); void set_dac_control(state_sequent* exp_sequence, state::iterator where, int input_shift_register); + + state_sequent *tx_bit(unsigned int bit); }; /*class pfg_exception: public std::string { diff --git a/drivers/Eurotherm-2000Series/CMakeLists.txt b/drivers/Eurotherm-2000Series/CMakeLists.txt new file mode 100644 index 0000000..f955e3f --- /dev/null +++ b/drivers/Eurotherm-2000Series/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.0) + +add_library(Eurotherm-2000Series Eurotherm-2000Series.cpp) \ No newline at end of file diff --git a/drivers/PTS-Synthesizer/CMakeLists.txt b/drivers/PTS-Synthesizer/CMakeLists.txt new file mode 100644 index 0000000..c6ae969 --- /dev/null +++ b/drivers/PTS-Synthesizer/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.0) + +add_library(PTS PTS.cpp) \ No newline at end of file diff --git a/drivers/Spectrum-M2i40xxSeries/CMakeLists.txt b/drivers/Spectrum-M2i40xxSeries/CMakeLists.txt new file mode 100644 index 0000000..cd4bae9 --- /dev/null +++ b/drivers/Spectrum-M2i40xxSeries/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.0) + +set( SPC_DRV drv_spcm_linux_drv_v214b5633.zip) +set(SPC_HEADERS + include/spcerr.h + include/regs.h + include/dlltyp.h + include/spcioctl.inc) + +add_custom_command(OUTPUT ${SPC_HEADERS} + COMMAND ${CMAKE_COMMAND} -E unzip -u ${SPC_DRV} "*.h" "*.txt" "*.inc" -d include/ + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include + COMMENT "Unpacking SPC headers" + VERBATIM) + +add_library(Spectrum-M2i40xxSeries STATIC Spectrum-M2i40xxSeries.cpp GatedData.cpp) \ No newline at end of file diff --git a/machines/CMakeLists.txt b/machines/CMakeLists.txt index 48d2429..6e15f0d 100644 --- a/machines/CMakeLists.txt +++ b/machines/CMakeLists.txt @@ -36,7 +36,7 @@ set(SOURCE_FILES add_executable(dummycore dummycore.cpp hardware.cpp) -target_link_libraries( dummycore pthread ${XERCES_LIBRARIES} core dummy Eurotherm-2000Series) +target_link_libraries( dummycore pthread ${XERCES_LIBRARIES} core dummy tempcont Eurotherm-2000Series) add_executable(PFGcore PFGcore.cpp hardware.cpp) target_link_libraries( PFGcore pthread ${XERCES_LIBRARIES} core Spectrum_MI40xxSeries PB PB24 PB_PROG PTS Tecmag-DAC20 )