diff --git a/doc/XPSTrajectory_user_manual.doc b/doc/XPSTrajectory_user_manual.doc index fa3f08815acbce37a22ad229a7b01b56e22651e6..08dfe6a8aacf4c21f95c67ae4a1ce206945d442b 100755 Binary files a/doc/XPSTrajectory_user_manual.doc and b/doc/XPSTrajectory_user_manual.doc differ diff --git a/pom.xml b/pom.xml index 4892b7887cf1d9b624ba4528f53f58d090afdf01..4196e05892697652e28531ef35d7884bcf9b8ace 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ <groupId>fr.soleil.device</groupId> <artifactId>XPSV2-${aol}-${mode}</artifactId> - <version>1.3.10-SNAPSHOT</version> + <version>1.4.0-SNAPSHOT</version> <packaging>nar</packaging> @@ -29,6 +29,14 @@ This field 'name' will define the name of the application. <plugin> <groupId>org.freehep</groupId> <artifactId>freehep-nar-plugin</artifactId> + <configuration> + <os>Linux</os> + <cpp> + <options> + <option>-DTU_TRAJECTORY_TESTS</option> + </options> + </cpp> + </configuration> </plugin> </plugins> </build> diff --git a/src/XPSAxis.cpp b/src/XPSAxis.cpp index 30bbdfff82a2af0475bed86cafba5a4c47b6dc55..dcedda80ea505deebfe0335eb7ec6ee53a090e76 100644 --- a/src/XPSAxis.cpp +++ b/src/XPSAxis.cpp @@ -1117,8 +1117,7 @@ void XPSAxis::write_backlashEnabled(Tango::WAttribute &attr) //----------------------------------------------------------------------------- void XPSAxis::Update () { -//#define TU_TRAJECTORY_TESTS -//#ifndef TU_TRAJECTORY_TESTS +#ifndef TU_TRAJECTORY_TESTS double offs = positioner->get_offset (); yat4tango::PropertyHelper::set_memorized_attribute(this, "offset", static_cast<double>(offs)); @@ -1139,7 +1138,7 @@ void XPSAxis::write_backlashEnabled(Tango::WAttribute &attr) yat4tango::PropertyHelper::set_memorized_attribute(this, "velocity", static_cast<double>(vel)); return; -//#endif +#endif } diff --git a/src/XPSLib/Group.cpp b/src/XPSLib/Group.cpp index b50819b03451b50360f6897c561ff6c8f1b6d9f3..7afa6393e0caae37d1f1c6ad29f64b294ec387b4 100644 --- a/src/XPSLib/Group.cpp +++ b/src/XPSLib/Group.cpp @@ -102,8 +102,10 @@ namespace xps_ns try { // //std::cout << "Group::initialize Socket Pool\n"; + #ifndef TU_TRAJECTORY_TESTS SocketPool::instance (); SocketPool::instance()->initialize (ip_conf); +#endif } catch (Tango::DevFailed &e) { @@ -189,6 +191,9 @@ namespace xps_ns { //- creation of the Trajectory trajectory = new Trajectory (traj_conf); +#ifndef TU_TRAJECTORY_TESTS +internal_state = Group::SW_INITIALIZED; +#endif } catch (Tango::DevFailed &e) { @@ -232,7 +237,9 @@ namespace xps_ns //std::cout << "Group::sw_run try to <sw_run> Socket Pool\n"; try { +#ifndef TU_TRAJECTORY_TESTS SocketPool::instance()->sw_run (); +#endif } catch (Tango::DevFailed &e) { @@ -281,7 +288,9 @@ namespace xps_ns //- start the periodic thread try { +#ifndef TU_TRAJECTORY_TESTS PeriodicTask::instance ()->sw_run (); +#endif } catch (...) { @@ -293,9 +302,10 @@ namespace xps_ns } internal_state = Group::SW_CONFIGURED; - +#ifndef TU_TRAJECTORY_TESTS //- initialize setpoints with current positions this->hw_get_positions (); +#endif // for (size_t i = 0; i < this->conf.positioner_names.size(); i++) { @@ -334,8 +344,9 @@ namespace xps_ns //- force the copy of READ part of positions in WRITE part this->previous_group_state = GRP_MOVING; - +#ifndef TU_TRAJECTORY_TESTS this->hw_get_xps_setpoints (); +#endif for (size_t i = 0; i < this->conf.positioner_names.size (); i++) tango_setpoints_internal [i].sp = positioners.at (i)->get_xps_setpoint () + positioners.at (i)->get_offset (); @@ -923,6 +934,7 @@ namespace xps_ns // ============================================================================ void Group::hw_get_xps_setpoints (void) { +#ifndef TU_TRAJECTORY_TESTS //- //std::cout << "Group::hw_get_setpoints" << std::endl; if (internal_state != SW_CONFIGURED) return; @@ -953,6 +965,7 @@ namespace xps_ns for (size_t i = 0; i < this->conf.positioner_names.size(); i++) positioners.at (i)->set_xps_setpoint (yat::IEEE_NAN); } +#endif } // ============================================================================ @@ -963,7 +976,7 @@ namespace xps_ns //- //std::cout << "Group::hw_get_group_status " << std::endl; if (internal_state != SW_CONFIGURED) return; - +#ifndef TU_TRAJECTORY_TESTS try { int s_n_b = SocketPool::instance()->get_non_blocking_socket(); @@ -986,6 +999,7 @@ namespace xps_ns // No valid state from HW xps_group_state = UNKNOWN_XPS_GROUP_STATE; } +#endif } // ============================================================================ // Group::hw_get_positions @@ -997,7 +1011,7 @@ namespace xps_ns //std::cerr << "Group::hw_get_positions internal_state is < " << class_states_str [this->internal_state] << ">\n"; return; } - +#ifndef TU_TRAJECTORY_TESTS try { // Get data from Hardware @@ -1024,7 +1038,7 @@ namespace xps_ns for (size_t i = 0; i < this->conf.positioner_names.size(); i++) positioners.at (i)->set_read_position (yat::IEEE_NAN); } - +#endif } // ============================================================================ diff --git a/src/XPSLib/Positioner.cpp b/src/XPSLib/Positioner.cpp index 1af1a3c45d4c7be77d5d8c0b4a8a0b4b42cf3afd..d3c980c6f47c057834d1c4c60b2226781d4dfb7c 100644 --- a/src/XPSLib/Positioner.cpp +++ b/src/XPSLib/Positioner.cpp @@ -103,6 +103,7 @@ namespace xps_ns //- get max acceleration, max velocity //std::cout << "Positioner::sw_run try to get vel, accel\n"; +#ifndef TU_TRAJECTORY_TESTS this->refresh_gamma_parameters(); //- get positioner soft limits @@ -113,6 +114,7 @@ namespace xps_ns //- only a few axes have triggers configured so do not check errors on trigger configuration //std::cout << "Positioner::sw_run try to get trigger parameters\n"; this->get_trigger_parameters (); +#endif } // ============================================================================ @@ -425,9 +427,9 @@ namespace xps_ns limits.tango.max = limits.tango.max + (offset - previous_offset); // Notify all our observers - - this->Notify (); - +#ifndef TU_TRAJECTORY_TESTS + this->Notify (); +#endif } //------------------------------------------- //- Positioner::set_velocity @@ -720,6 +722,7 @@ namespace xps_ns // ============================================================================ void Positioner::throw_on_error (std::string origin, int return_code) { +#ifndef TU_TRAJECTORY_TESTS //- //std::cout << "Positioner::throw_on_error <-" << std::endl; if (return_code == 0) return; @@ -738,6 +741,7 @@ namespace xps_ns THROW_DEVFAILED("COMMAND_ERROR", ret_code_string, origin.c_str ()); +#endif } //- TANGODEVIC-57: diff --git a/src/XPSLib/SocketPool.cpp b/src/XPSLib/SocketPool.cpp index 2facca7333f40c4a78593447f0d4aa788880966e..bfd5d5cfabed470c6152bede3797e15a63569be1 100644 --- a/src/XPSLib/SocketPool.cpp +++ b/src/XPSLib/SocketPool.cpp @@ -386,6 +386,7 @@ int SocketPool::get_blocking_socket() //---------------------------------------- int SocketPool::get_non_blocking_socket() { +#ifndef TU_TRAJECTORY_TESTS int socketItem_with_comm_error = -1; yat::AutoMutex <yat::Mutex> guard (this->non_block_sock_mutex); @@ -421,6 +422,7 @@ int SocketPool::get_non_blocking_socket() THROW_DEVFAILED ("OPERATION_NOT_ALLOWED", "All <<Non Blocking Sockets>> (used for non blocking commands) are used", "SocketPool::get_non_blocking_socket()"); +#endif } @@ -429,6 +431,7 @@ int SocketPool::get_non_blocking_socket() //----------------------------------------------- void SocketPool::SendAndReceive(int socketID, char sSendString[], char sReturnString[], int iReturnStringSize) { +#ifndef TU_TRAJECTORY_TESTS if (socketID < SOCK_BLOCK_MIN_NUMBER || socketID > SOCK_NONBLOCK_MAX_NUMBER) { //std::cerr << "SocketPool::SendAndReceive SOFTWARE_FAILURE socket number out of range [call software support]" << std::endl; @@ -464,6 +467,7 @@ void SocketPool::SendAndReceive(int socketID, char sSendString[], char sReturnSt _CPTC("xps_ns::SocketPool::SendAndReceive - MAX_COM_RETRY is reached."), _CPTC("xps_ns::SocketPool::SendAndReceive")); } +#endif } //------------------------------------------------ diff --git a/src/XPSLib/Trajectory.cpp b/src/XPSLib/Trajectory.cpp index 4feaaee37ecc88ec6087962f205f8f9830912d29..e503bb0b2f9394d6ed6a16306e4eeae3881e4420 100644 --- a/src/XPSLib/Trajectory.cpp +++ b/src/XPSLib/Trajectory.cpp @@ -77,7 +77,9 @@ namespace xps_ns //- retreive positioner infos : group name, positioner name, soft limits,... try { +#ifndef TU_TRAJECTORY_TESTS this->get_positioners_infos (); +#endif class_state = SW_CONFIGURED; } catch (...) @@ -365,7 +367,9 @@ namespace xps_ns else if (traj_state == TRAJ_RUNNING_TRAJ) traj_state = TRAJ_DONE; } - +#ifdef TU_TRAJECTORY_TESTS + traj_state = TRAJ_CHECK_OK; +#endif return traj_state; } @@ -450,7 +454,7 @@ namespace xps_ns void Trajectory::throw_on_error (std::string origin, int return_code) { //std::cout << "Trajectory::throw_on_error <-" << std::endl; - + #ifndef TU_TRAJECTORY_TESTS if (return_code == 0) return; @@ -465,6 +469,7 @@ namespace xps_ns THROW_DEVFAILED("COMMAND_ERROR", ret_code_string, origin.c_str ()); +#endif } @@ -522,10 +527,10 @@ namespace xps_ns this->traj_type = TRAJ_ABSOLUTE_POS; this->check_pvt_input (dim_x, dim_y, pvt); - +#ifndef TU_TRAJECTORY_TESTS //- OK? clear the XPS and internal buffers this->clear (); - +#endif this->initialize_member_variables (dim_y); @@ -587,19 +592,20 @@ namespace xps_ns this->fill_relative_times_vector (pre_time_max, post_time_max, dim_y); this->fill_positions_vector (pre_time_max, post_time_max); - +#ifndef TU_TRAJECTORY_TESTS //- check absolute trajectory and the absolute start and stop positions after they have been computed this->check_abs_traj_for_user_limits (); - +#endif this->display_trajectory (); //- OKAYYYYY cool man traj_state = TRAJ_INPUT_PROCESSED; - +#ifndef TU_TRAJECTORY_TESTS //- upload the trajectory this->trajectory_upload (); //- request XPS to check the trajectory for possible errors this->check (); +#endif //- go to origin // this->go_to_origin (); } @@ -626,10 +632,10 @@ namespace xps_ns this->check_abs_pt_input (dim_x, dim_y, pt); //- la trajectoire est fournie en points "utiles" cad en mouvement - +#ifndef TU_TRAJECTORY_TESTS //- OK? clear the XPS and internal buffers this->clear (); - +#endif this->initialize_member_variables (dim_y); //- spécifique PT (l'image en entrée contient temps, et positions) @@ -709,10 +715,10 @@ namespace xps_ns this->fill_relative_times_vector (pre_time_max, post_time_max, dim_y); this->fill_positions_vector (pre_time_max, post_time_max); - +#ifndef TU_TRAJECTORY_TESTS //- check absolute trajectory and the absolute start and stop positions after they have been computed this->check_abs_traj_for_user_limits (); - +#endif //- Specific to load_abs_pt : compute the velocities double T0 = 0.; @@ -757,9 +763,11 @@ namespace xps_ns //- OKAYYYYY cool man traj_state = TRAJ_INPUT_PROCESSED; +#ifndef TU_TRAJECTORY_TESTS //- upload the trajectory this->trajectory_upload (); +#endif //- request XPS to check the trajectory for possible errors //this->check (); // TODO remettre l'envoi en position initiale? @@ -1027,29 +1035,32 @@ namespace xps_ns void Trajectory::display_trajectory (void) { //- afficher point départ/arrivée absolus +#ifdef TU_TRAJECTORY_TESTS + for (size_t i = 0; i < positioners_infos.size (); i++) { - /* - std::cout << "Trajectory::load_abs_pt positioner <" + + std::cout << "Trajectory::display_trajectory <" << positioners_infos [i].group_name << "." << positioners_infos [i].positioner_name << " first point abs. coord. <" << positioners_infos [i].start_pos_abs << " last point abs. coord. <" << positioners_infos [i].end_pos_abs << ">" << std::endl; - */ + } //- Afficher la trajectoire (temps/positions relatives) complete //std::cout << "DEBUG: Trajectory::display_relative_trajectory : display the relative trajectory\n"; for (size_t i = 0; i < traj_times_rel.size (); i++) { - //std::cout << "[dT<" << traj_times_rel [i] << ">; "; + std::cout << "[dT<" << traj_times_rel [i] << ">; "; for (size_t j = 0; j < positioners_infos.size (); j++) { - //std::cout << "dP[" << j << "]<" << positioners_infos [j].rel_pos [i] << ">;"; - //std::cout << " V[" << j << "]" <<positioners_infos [j].vel [i] << ">; "; + std::cout << "dP[" << j << "]<" << positioners_infos [j].rel_pos [i] << ">;"; + std::cout << " V[" << j << "]" <<positioners_infos [j].vel [i] << ">; "; } - //std::cout << "]" << std::endl; + std::cout << "]" << std::endl; } +#endif return; } // ============================================================================================================= @@ -1075,12 +1086,12 @@ namespace xps_ns //- throws exception if something was wrong in argins or class state, do not catch it this->traj_type = TRAJ_ABSOLUTE_POS; - //- check dim_x, dim_y and pvt size integrity - this->check_pvt_input (dim_x, dim_y, pt); -// #ifndef TU_TRAJECTORY_TESTS + //- check dim_x, dim_y and pt size integrity + this->check_abs_pt_input (dim_x, dim_y, pt); +#ifndef TU_TRAJECTORY_TESTS //- OK? clear the XPS and internal buffers this->clear (); -// #endif +#endif //- intialize the members avariables for new py algorithm this->initialize_sixs_py_algorithm_member_variables (dim_y); @@ -1193,13 +1204,13 @@ namespace xps_ns //- traj_state = TRAJ_INPUT_PROCESSED; -// #ifndef TU_TRAJECTORY_TESTS +#ifndef TU_TRAJECTORY_TESTS //- upload the trajectory to XPS controller this->trajectory_upload (); //- request XPS controller to check the trajectory for possible errors this->check (); -// #endif +#endif } // ============================================================================ @@ -1246,9 +1257,9 @@ namespace xps_ns //- Check all positions of the trajectory are among user limits for (size_t i = 0; i < positioners_infos.size (); i++) { -// #ifdef TU_TRAJECTORY_TESTS +#ifdef TU_TRAJECTORY_TESTS std::cout<<"positioner<"<<i<<"> Limits ["<<positioners_infos [i].soft_limit_min<<", "<<positioners_infos [i].soft_limit_max<<"]"<<endl; -// #endif +#endif //- All others positions in the trajectory @@ -1269,9 +1280,9 @@ std::cout<<"positioner<"<<i<<"> Limits ["<<positioners_infos [i].soft_limit_ s.str ().c_str (), "Trajectory::check_sixs_py_algorithm_abs_traj_for_user_limits"); } - // #ifdef TU_TRAJECTORY_TESTS + #ifdef TU_TRAJECTORY_TESTS std::cout<<" abs <"<<positioners_infos [i].abs_pos [j]<<"> "<<endl; - // #endif + #endif } //- end for all abs points } //- end check soft limits } @@ -1313,7 +1324,7 @@ std::cout<<"positioner<"<<i<<"> Limits ["<<positioners_infos [i].soft_limit_ //- afficher point départ/arrivée absolus for (size_t i = 0; i < positioners_infos.size (); i++) { - std::cout << "Trajectory::load_abs_pt positioner <" + std::cout << "Trajectory::display_sixs_py_algorithm_trajectory <" << positioners_infos [i].group_name << "." << positioners_infos [i].positioner_name << " first point abs. coord. <" << positioners_infos [i].abs_pos[0] << "> last point abs. coord. <" << positioners_infos [i].abs_pos[dim_y + 1] diff --git a/src/XPSTrajectory.cpp b/src/XPSTrajectory.cpp index 58a695e0dbb322481eaf7c1b4740d064351c4dce..47ffe70854b74111a7006ebbd3ade0ee50be9dd7 100644 --- a/src/XPSTrajectory.cpp +++ b/src/XPSTrajectory.cpp @@ -292,6 +292,7 @@ void XPSTrajectory::write_pvt(Tango::WAttribute &attr) << " longueur ligne (dim_x) " << dim_x << " nb lignes (dim_y) " << dim_y << std::endl; */ + positions.clear(); for (size_t i = 0; i < size; i ++) positions.push_back (p[i]);