text:
#include <stdio.h>
#include <ur_rtde/rtde_control_interface.h>
#include <ur_rtde/rtde_io_interface.h>
#include <ur_rtde/rtde_receive_interface.h>

#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include <chrono>
#include <iostream>
#include <thread>

using namespace ur_rtde;
using namespace std::chrono;

//*自定义校验和函数
char checkSum(unsigned char *sendBuffer)
{
  int sum = 0;

  for (size_t i = 2; i < 8; i++)
  {
    sum = sum + sendBuffer[i];
  }

  sendBuffer[8] = sum;
  sum = 0;
}

//************************************

int main(int argc, char *argv[])
{
  //** 串口初始化 **//
  boost::asio::io_service ioService;
  boost::asio::serial_port serialPort(ioService, "/dev/ttyUSB0");

  serialPort.set_option(boost::asio::serial_port::baud_rate(115200));
  serialPort.set_option(boost::asio::serial_port::flow_control(boost::asio::serial_port::flow_control::none));
  serialPort.set_option(boost::asio::serial_port::parity(boost::asio::serial_port::parity::none));
  serialPort.set_option(boost::asio::serial_port::stop_bits(boost::asio::serial_port::stop_bits::one));
  serialPort.set_option(boost::asio::serial_port::character_size(8));

  unsigned char sendBuffer[] = {0x55, 0XAA, 0x04, 0x02, 0x03, 0x37, 0x00, 0x00, 0X58};

  //**-------------------------------**//

  //**************************************连接UR***********************************************************************//
  ur_rtde::RTDEControlInterface rtde_control("192.168.3.101");
  ur_rtde::RTDEReceiveInterface rtde_receive("192.168.3.101");
  ur_rtde::RTDEIOInterface rtde_io("192.168.3.101");
  //*---------------------------------------------------------------------------------------------------------------*//

  //****************定义路点*************************/

  //初始点
  std::vector<double> initialPoint = {-0.43212,-0.15122,0.3796,2.294,2.089,0.057};

  // Box路点
  std::vector<double> boxHighPoint1 = {0.66242,-0.23972,0.30066,2.290,2.090,0.058};
  std::vector<double> boxHighPoint2 = {0.67166,-0.24022,0.30066,2.294,2.089,0.057};
  std::vector<double> boxHighPoint3 = {0.68058,-0.24096,0.30066,2.294,2.089,0.057};
  std::vector<double> boxHighPoint4 = {0.68956,-0.24156,0.30066,2.294,2.089,0.057};
  std::vector<double> boxHighPoint5 = {0.69836,-0.24276,0.30066,2.294,2.089,0.057};
  std::vector<double> boxHighPoint6 = {0.70810,-0.24350,0.30066,2.294,2.089,0.057};
  std::vector<double> boxHighPoint7 = {0.71688,-0.24446,0.30066,2.294,2.089,0.057};
  std::vector<double> boxHighPoint8 = {0.72552,-0.24532,0.30066,2.294,2.089,0.057};
  std::vector<double> boxMidPoint1  = {0.66242,-0.23972,0.22040,2.290,2.090,0.058};
  std::vector<double> boxMidPoint2  = {0.67166,-0.24022,0.22216,2.294,2.089,0.057};
  std::vector<double> boxMidPoint3  = {0.68058,-0.24096,0.22116,2.294,2.089,0.057};
  std::vector<double> boxMidPoint4  = {0.68956,-0.24156,0.22212,2.294,2.089,0.057};
  std::vector<double> boxMidPoint5  = {0.69836,-0.24276,0.22276,2.294,2.089,0.057};
  std::vector<double> boxMidPoint6  = {0.70810,-0.24350,0.22316,2.294,2.089,0.057};
  std::vector<double> boxMidPoint7  = {0.71688,-0.24446,0.22146,2.294,2.089,0.057};
  std::vector<double> boxMidPoint8  = {0.72552,-0.24532,0.22210,2.294,2.089,0.057};

  //蒸馏水路点
  std::vector<double> waterHighPoint = {0.55272,0.00036,0.30066,2.294,2.089,0.057};

  std::vector<double> waterLowPoint = {0.55272,0.000036,0.20266,2.294,2.089,0.057};

  //待稀释溶液路点
  std::vector<double> blackHighPoint = {0.52648,-0.19666,0.30066,2.294,2.089,0.057};

  std::vector<double> blackLowPoint = {0.52646,-0.19666,0.20266,2.294,2.089,0.057};

  //工作版路点
  std::vector<double> wellHighPoint1 = {0.66886,-0.00876,0.26666,2.294,2.089,0.057};
  std::vector<double> wellHighPoint2 = {0.67631,-0.00876,0.26666,2.294,2.089,0.057};
  std::vector<double> wellMidPoint1  = {0.66888,-0.00876,0.23888,2.294,2.089,0.057};
  std::vector<double> wellMidPoint2  = {0.67631,-0.00876,0.23672,2.294,2.089,0.057};
  std::vector<double> wellLowPoint1  = {0.66888,-0.00876,0.21666,2.294,2.089,0.057};
  std::vector<double> wellLowPoint2  = {0.67631,-0.00876,0.21666,2.294,2.089,0.057};

  // medical waste路点
  std::vector<double> trashPoint = {0.56286,-0.41600,0.26066,2.294,2.089,0.057};

  //*******************开始操作****************目标：倍比稀释**********************稀释倍数：4*********//

  //**********************************到达初始位置，准备开始工作***************************************/

  rtde_control.moveL(initialPoint, 0.5, 0.2);

  //*****************************************************************************************************/

  //************取第一排吸头，然后吸取12*50=600微升蒸馏水到工作板第一排，扔掉吸头并回到初始点准备下一个操作******/

  //取第一排吸头
  rtde_control.moveL({boxHighPoint1}, 0.5, 0.2);
  rtde_control.moveL({boxMidPoint1}, 0.5, 0.2);
  // Parameters
  std::vector<double> task_frame    = {0, 0, 0, 0, 0, 0};
  std::vector<int> selection_vector = {0, 0, 1, 0, 0, 0};
  std::vector<double> wrench_down   = {0, 0, -20, 0, 0, 0};
  std::vector<double> wrench_up     = {0, 0, 1, 0, 0, 0};
  int    force_type = 2;
  double dt         = 1.0/500;  // 2ms
  std::vector<double> limits = {1, 1, 1, 1, 1, 1};

  // Execute 500Hz control loop for a total of 4 seconds, each cycle is ~2ms
  for (unsigned int i=0; i<4000; i++)
  {
    auto t_start = high_resolution_clock::now();
    // First we move the robot down for 2 seconds, then up for 2 seconds
    if (i > 2000)
      rtde_control.forceMode(task_frame, selection_vector, wrench_up, force_type, limits);
    else
      rtde_control.forceMode(task_frame, selection_vector, wrench_down, force_type, limits);
    auto t_stop     = high_resolution_clock::now();
    auto t_duration = std::chrono::duration<double>(t_stop - t_start);

    if (t_duration.count() < dt)
    {
      std::this_thread::sleep_for(std::chrono::duration<double>(dt - t_duration.count()));
    }
  }
  rtde_control.forceModeStop();

  rtde_control.moveL({boxHighPoint1}, 0.5, 0.2);

  //吸取蒸馏水
  rtde_control.moveL({waterHighPoint}, 0.5, 0.2);

  {
    sendBuffer[3] = {0x01};
    sendBuffer[6] = {0xD0};
    sendBuffer[7] = {0x07};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));
  }

  rtde_control.moveL({waterLowPoint}, 0.5, 0.2);

  {
    sendBuffer[3] = {0x01};
    sendBuffer[6] = {0x00};
    sendBuffer[7] = {0x00};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));
  }

  rtde_control.moveL({waterHighPoint}, 0.5, 0.2);

  //排到工作板第一排

  rtde_control.moveL({wellHighPoint1}, 0.5, 0.2);
  rtde_control.moveL({wellMidPoint1}, 0.5, 0.2);
  {
    sendBuffer[3] = {0x01};
    sendBuffer[6] = {0xD0};
    sendBuffer[7] = {0x07};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

  }
  rtde_control.moveL({wellHighPoint1}, 0.5, 0.2);

  //扔掉吸头
  rtde_control.moveL({trashPoint}, 0.5, 0.2);
  {
    sendBuffer[3] = {0x02};
    sendBuffer[6] = {0xD0};
    sendBuffer[7] = {0x07};
    checkSum(sendBuffer);
      serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

sendBuffer[3] = {0x02};
    sendBuffer[6] = {0x00};
    sendBuffer[7] = {0x00};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

  }

  //回到初始点
  rtde_control.moveL(initialPoint, 0.5, 0.2);
  //*****************************************************************************************************/

  //*************取第二排吸头，然后吸取12*50=600微升蒸馏水到工作板第一排，扔掉吸头并回到初始点准备下一个操作************//

  //取第二排吸头
  rtde_control.moveL({boxHighPoint2}, 0.5, 0.2);
  rtde_control.moveL({boxMidPoint2}, 0.5, 0.2);

  // Execute 500Hz control loop for a total of 4 seconds, each cycle is ~2ms
  for (unsigned int i=0; i<4000; i++)
  {
    auto t_start = high_resolution_clock::now();
    // First we move the robot down for 2 seconds, then up for 2 seconds
    if (i > 2000)
      rtde_control.forceMode(task_frame, selection_vector, wrench_up, force_type, limits);
    else
      rtde_control.forceMode(task_frame, selection_vector, wrench_down, force_type, limits);
    auto t_stop     = high_resolution_clock::now();
    auto t_duration = std::chrono::duration<double>(t_stop - t_start);

    if (t_duration.count() < dt)
    {
      std::this_thread::sleep_for(std::chrono::duration<double>(dt - t_duration.count()));
    }
  }
  rtde_control.forceModeStop();

  rtde_control.moveL({boxHighPoint2}, 0.5, 0.2);

  //吸取蒸馏水
  rtde_control.moveL({waterHighPoint}, 0.5, 0.2);
  {
    sendBuffer[3] = {0x01};
    sendBuffer[6] = {0xD0};
    sendBuffer[7] = {0x07};
    checkSum(sendBuffer);
     serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

  }
  rtde_control.moveL({waterLowPoint}, 0.5, 0.2);

  {
    sendBuffer[3] = {0x01};
    sendBuffer[6] = {0x00};
    sendBuffer[7] = {0x00};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

  }
  rtde_control.moveL({waterHighPoint}, 0.5, 0.2);

  //排到工作板第一排

  rtde_control.moveL({wellHighPoint1}, 0.5, 0.2);
  rtde_control.moveL({wellMidPoint1}, 0.5, 0.2);
  {
sendBuffer[3] = {0x01};
    sendBuffer[6] = {0xD0};
    sendBuffer[7] = {0x07};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

  }
  rtde_control.moveL({wellHighPoint1}, 0.5, 0.2);

  //扔掉吸头
  rtde_control.moveL({trashPoint}, 0.5, 0.2);
    {
    sendBuffer[3] = {0x02};
    sendBuffer[6] = {0xD0};
    sendBuffer[7] = {0x07};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

sendBuffer[3] = {0x02};
    sendBuffer[6] = {0x00};
    sendBuffer[7] = {0x00};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

  }
  //回到初始点
  rtde_control.moveL(initialPoint, 0.5, 0.2);

  //*****************************************************************************************************/

  //*******************取第三排吸头，然后吸取12*50=600微升蒸馏水到工作板第一排，扔掉吸头并回到初始点准备下一个操作**************/
  //取第三排吸头
  rtde_control.moveL({boxHighPoint3}, 0.5, 0.2);
  rtde_control.moveL({boxMidPoint3}, 0.5, 0.2);
   // Execute 500Hz control loop for a total of 4 seconds, each cycle is ~2ms
  for (unsigned int i=0; i<4000; i++)
  {
    auto t_start = high_resolution_clock::now();
    // First we move the robot down for 2 seconds, then up for 2 seconds
    if (i > 2000)
      rtde_control.forceMode(task_frame, selection_vector, wrench_up, force_type, limits);
    else
      rtde_control.forceMode(task_frame, selection_vector, wrench_down, force_type, limits);
    auto t_stop     = high_resolution_clock::now();
    auto t_duration = std::chrono::duration<double>(t_stop - t_start);

    if (t_duration.count() < dt)
    {
      std::this_thread::sleep_for(std::chrono::duration<double>(dt - t_duration.count()));
    }
  }
  rtde_control.forceModeStop();

  rtde_control.moveL({boxHighPoint3}, 0.5, 0.2);

  //吸取蒸馏水
  rtde_control.moveL({waterHighPoint}, 0.5, 0.2);

  {
    sendBuffer[3] = {0x01};
    sendBuffer[6] = {0xD0};
    sendBuffer[7] = {0x07};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
  }
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

  rtde_control.moveL({waterLowPoint}, 0.5, 0.2);

  {
    sendBuffer[3] = {0x01};
    sendBuffer[6] = {0x00};
    sendBuffer[7] = {0x00};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

  }

  rtde_control.moveL({waterHighPoint}, 0.5, 0.2);

  //排到工作板第一排

  rtde_control.moveL({wellHighPoint1}, 0.5, 0.2);
  rtde_control.moveL({wellMidPoint1}, 0.5, 0.2);
  {
 sendBuffer[3] = {0x01};
    sendBuffer[6] = {0xD0};
    sendBuffer[7] = {0x07};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

  }
  rtde_control.moveL({wellHighPoint1}, 0.5, 0.2);
  //扔掉吸头
  rtde_control.moveL({trashPoint}, 0.5, 0.2);
   {
    sendBuffer[3] = {0x02};
    sendBuffer[6] = {0xD0};
    sendBuffer[7] = {0x07};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

sendBuffer[3] = {0x02};
    sendBuffer[6] = {0x00};
    sendBuffer[7] = {0x00};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

  }
  //回到初始点
  rtde_control.moveL(initialPoint, 0.5, 0.2);

  //*****************************************************************************************************/

  //**************取第四排吸头，然后吸取12*50=600微升蒸馏水到工作板第二排，扔掉吸头并回到初始点准备下一个操作
  //取第四排吸头
  rtde_control.moveL({boxHighPoint4}, 0.5, 0.2);
  rtde_control.moveL({boxMidPoint4}, 0.5, 0.2);

  // Execute 500Hz control loop for a total of 4 seconds, each cycle is ~2ms
  for (unsigned int i=0; i<4000; i++)
  {
    auto t_start = high_resolution_clock::now();
    // First we move the robot down for 2 seconds, then up for 2 seconds
    if (i > 2000)
      rtde_control.forceMode(task_frame, selection_vector, wrench_up, force_type, limits);
    else
      rtde_control.forceMode(task_frame, selection_vector, wrench_down, force_type, limits);
    auto t_stop     = high_resolution_clock::now();
    auto t_duration = std::chrono::duration<double>(t_stop - t_start);

    if (t_duration.count() < dt)
    {
      std::this_thread::sleep_for(std::chrono::duration<double>(dt - t_duration.count()));
    }
  }
  rtde_control.forceModeStop();

  rtde_control.moveL({boxHighPoint4}, 0.5, 0.2);

  //吸取蒸馏水
  rtde_control.moveL({waterHighPoint}, 0.5, 0.2);

  {
    sendBuffer[3] = {0x01};
    sendBuffer[6] = {0xD0};
    sendBuffer[7] = {0x07};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

  }

  rtde_control.moveL({waterLowPoint}, 0.5, 0.2);

  {
    sendBuffer[3] = {0x01};
    sendBuffer[6] = {0x00};
    sendBuffer[7] = {0x00};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

  }

  rtde_control.moveL({waterHighPoint}, 0.5, 0.2);

  //排到工作板第二排
  rtde_control.moveL({wellHighPoint2}, 0.5, 0.2);
  rtde_control.moveL({wellMidPoint2}, 0.5, 0.2);
  {
    sendBuffer[3] = {0x01};
    sendBuffer[6] = {0xD0};
    sendBuffer[7] = {0x07};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

  }
  rtde_control.moveL({wellHighPoint1}, 0.5, 0.2);
  //扔掉吸头
  rtde_control.moveL({trashPoint}, 0.5, 0.2);
   {
    sendBuffer[3] = {0x02};
    sendBuffer[6] = {0xD0};
    sendBuffer[7] = {0x07};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

sendBuffer[3] = {0x02};
    sendBuffer[6] = {0x00};
    sendBuffer[7] = {0x00};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

  }
  //回到初始点
  rtde_control.moveL(initialPoint, 0.5, 0.2);
  //*****************************************************************************************************/

  //************************取第五排吸头，然后吸取12*50=600微升蒸馏水到工作板第二排，扔掉吸头并回到初始点准备下一个操作********//

  //取第五排吸头
  rtde_control.moveL({boxHighPoint5}, 0.5, 0.2);
  rtde_control.moveL({boxMidPoint5}, 0.5, 0.2);

  // Execute 500Hz control loop for a total of 4 seconds, each cycle is ~2ms
  for (unsigned int i=0; i<4000; i++)
  {
    auto t_start = high_resolution_clock::now();
    // First we move the robot down for 2 seconds, then up for 2 seconds
    if (i > 2000)
      rtde_control.forceMode(task_frame, selection_vector, wrench_up, force_type, limits);
    else
      rtde_control.forceMode(task_frame, selection_vector, wrench_down, force_type, limits);
    auto t_stop     = high_resolution_clock::now();
    auto t_duration = std::chrono::duration<double>(t_stop - t_start);

    if (t_duration.count() < dt)
    {
      std::this_thread::sleep_for(std::chrono::duration<double>(dt - t_duration.count()));
    }
  }
  rtde_control.forceModeStop();

  rtde_control.moveL({boxHighPoint5}, 0.5, 0.2);

  //吸取蒸馏水
  rtde_control.moveL({waterHighPoint}, 0.5, 0.2);

  {
    sendBuffer[3] = {0x01};
    sendBuffer[6] = {0xD0};
    sendBuffer[7] = {0x07};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

  }

  rtde_control.moveL({waterLowPoint}, 0.5, 0.2);

  {
    sendBuffer[3] = {0x01};
    sendBuffer[6] = {0x00};
    sendBuffer[7] = {0x00};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

  }

  rtde_control.moveL({waterHighPoint}, 0.5, 0.2);

  //排到工作板第二排
  rtde_control.moveL({wellHighPoint2}, 0.5, 0.2);
  rtde_control.moveL({wellMidPoint2}, 0.5, 0.2);
  {
    sendBuffer[3] = {0x01};
    sendBuffer[6] = {0xD0};
    sendBuffer[7] = {0x07};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

  }
  rtde_control.moveL({wellHighPoint2}, 0.5, 0.2);
  //扔掉吸头
  rtde_control.moveL({trashPoint}, 0.5, 0.2);
  {
    sendBuffer[3] = {0x02};
    sendBuffer[6] = {0xD0};
    sendBuffer[7] = {0x07};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

sendBuffer[3] = {0x02};
    sendBuffer[6] = {0x00};
    sendBuffer[7] = {0x00};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

  }
  //回到初始点
  rtde_control.moveL(initialPoint, 0.5, 0.2);

  //*****************************************************************************************************

  //********************取第六排吸头，然后吸取12*50=600微升蒸馏水到工作板第二排，扔掉吸头并回到初始点准备下一个操作***************//

  //取第六排吸头

  rtde_control.moveL({boxHighPoint6}, 0.5, 0.2);
  rtde_control.moveL({boxMidPoint6}, 0.5, 0.2);

  // Execute 500Hz control loop for a total of 4 seconds, each cycle is ~2ms
  for (unsigned int i=0; i<4000; i++)
  {
    auto t_start = high_resolution_clock::now();
    // First we move the robot down for 2 seconds, then up for 2 seconds
    if (i > 2000)
      rtde_control.forceMode(task_frame, selection_vector, wrench_up, force_type, limits);
    else
      rtde_control.forceMode(task_frame, selection_vector, wrench_down, force_type, limits);
    auto t_stop     = high_resolution_clock::now();
    auto t_duration = std::chrono::duration<double>(t_stop - t_start);

    if (t_duration.count() < dt)
    {
      std::this_thread::sleep_for(std::chrono::duration<double>(dt - t_duration.count()));
    }
  }
  rtde_control.forceModeStop();

  rtde_control.moveL({boxHighPoint6}, 0.5, 0.2);

  //吸取蒸馏水

  rtde_control.moveL({waterHighPoint}, 0.5, 0.2);

  {
    sendBuffer[3] = {0x01};
    sendBuffer[6] = {0xD0};
    sendBuffer[7] = {0x07};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

  }

  rtde_control.moveL({waterLowPoint}, 0.5, 0.2);

  {
    sendBuffer[3] = {0x01};
    sendBuffer[6] = {0x00};
    sendBuffer[7] = {0x00};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

  }

  rtde_control.moveL({waterHighPoint}, 0.5, 0.2);

  //排到工作板第二排

  rtde_control.moveL({wellHighPoint2}, 0.5, 0.2);
  rtde_control.moveL({wellMidPoint2}, 0.5, 0.2);

  {
 sendBuffer[3] = {0x01};
    sendBuffer[6] = {0xD0};
    sendBuffer[7] = {0x07};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

  }

  rtde_control.moveL({wellHighPoint2}, 0.5, 0.2);

  //扔掉吸头
  rtde_control.moveL({trashPoint}, 0.5, 0.2);
  {
    sendBuffer[3] = {0x02};
    sendBuffer[6] = {0xD0};
    sendBuffer[7] = {0x07};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

sendBuffer[3] = {0x02};
    sendBuffer[6] = {0x00};
    sendBuffer[7] = {0x00};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

  }

  //回到初始点
  rtde_control.moveL(initialPoint, 0.5, 0.2);

  //*****************************************************************************************************/

  //***********取第七排吸头，然后吸取12*50=600微升待稀释溶液到工作板第一排，扔掉吸头并回到初始点准备下一个操作***********//

  //取第七排吸头
  rtde_control.moveL({boxHighPoint7}, 0.5, 0.2);
  rtde_control.moveL({boxMidPoint7}, 0.5, 0.2);

  // Execute 500Hz control loop for a total of 4 seconds, each cycle is ~2ms
  for (unsigned int i=0; i<4000; i++)
  {
    auto t_start = high_resolution_clock::now();
    // First we move the robot down for 2 seconds, then up for 2 seconds
    if (i > 2000)
      rtde_control.forceMode(task_frame, selection_vector, wrench_up, force_type, limits);
    else
      rtde_control.forceMode(task_frame, selection_vector, wrench_down, force_type, limits);
    auto t_stop     = high_resolution_clock::now();
    auto t_duration = std::chrono::duration<double>(t_stop - t_start);

    if (t_duration.count() < dt)
    {
      std::this_thread::sleep_for(std::chrono::duration<double>(dt - t_duration.count()));
    }
  }
  rtde_control.forceModeStop();

  rtde_control.moveL({boxHighPoint7}, 0.5, 0.2);

  //吸取待稀释溶液
  rtde_control.moveL({blackHighPoint}, 0.5, 0.2);
   {
    sendBuffer[3] = {0x01};
    sendBuffer[6] = {0xD0};
    sendBuffer[7] = {0x07};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

  }
  rtde_control.moveL({blackLowPoint}, 0.5, 0.2);
  {
    sendBuffer[3] = {0x01};
    sendBuffer[6] = {0x00};
    sendBuffer[7] = {0x00};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

  }

  rtde_control.moveL({blackHighPoint}, 0.5, 0.2);
  //排到工作板第一排

  rtde_control.moveL({wellHighPoint1}, 0.5, 0.2);
  rtde_control.moveL({wellMidPoint1}, 0.5, 0.2);
  {
    sendBuffer[3] = {0x01};
    sendBuffer[6] = {0xD0};
    sendBuffer[7] = {0x07};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

  }

  //混合均匀
  rtde_control.moveL({wellLowPoint1}, 0.5, 0.2);

  {
    sendBuffer[3] = {0x01};
    sendBuffer[6] = {0x00};
    sendBuffer[7] = {0x00};
    checkSum(sendBuffer);
     serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

    sendBuffer[3] = {0x01};
    sendBuffer[6] = {0xD0};
    sendBuffer[7] = {0x07};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

    sendBuffer[3] = {0x01};
    sendBuffer[6] = {0x00};
    sendBuffer[7] = {0x00};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

    sendBuffer[3] = {0x01};
    sendBuffer[6] = {0xD0};
    sendBuffer[7] = {0x07};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

      sendBuffer[3] = {0x01};
    sendBuffer[6] = {0x00};
    sendBuffer[7] = {0x00};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

    sendBuffer[3] = {0x01};
    sendBuffer[6] = {0xD0};
    sendBuffer[7] = {0x07};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

  }

  rtde_control.moveL({wellHighPoint1}, 0.5, 0.2);
  //扔掉吸头

  rtde_control.moveL({trashPoint}, 0.5, 0.2);
  {
    sendBuffer[3] = {0x02};
    sendBuffer[6] = {0xD0};
    sendBuffer[7] = {0x07};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

sendBuffer[3] = {0x02};
    sendBuffer[6] = {0x00};
    sendBuffer[7] = {0x00};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

  }
  //回到初始点
  rtde_control.moveL(initialPoint, 0.5, 0.2);

  //*****************************************************************************************************/

  //****取第八排吸头，然后吸取12*50=600微升蒸馏水到工作板第二排，扔掉吸头并回到初始点，倍比稀释完毕********************/

  //取第八排吸头
  rtde_control.moveL({boxHighPoint8}, 0.5, 0.2);
  rtde_control.moveL({boxMidPoint8}, 0.5, 0.2);

  // Execute 500Hz control loop for a total of 4 seconds, each cycle is ~2ms
  for (unsigned int i=0; i<4000; i++)
  {
    auto t_start = high_resolution_clock::now();
    // First we move the robot down for 2 seconds, then up for 2 seconds
    if (i > 2000)
      rtde_control.forceMode(task_frame, selection_vector, wrench_up, force_type, limits);
    else
      rtde_control.forceMode(task_frame, selection_vector, wrench_down, force_type, limits);
    auto t_stop     = high_resolution_clock::now();
    auto t_duration = std::chrono::duration<double>(t_stop - t_start);

    if (t_duration.count() < dt)
    {
      std::this_thread::sleep_for(std::chrono::duration<double>(dt - t_duration.count()));
    }
  }
  rtde_control.forceModeStop();

  rtde_control.moveL({boxHighPoint8}, 0.5, 0.2);

  //吸取待稀释溶液
  rtde_control.moveL({blackHighPoint}, 0.5, 0.2);
  {
    sendBuffer[3] = {0x01};
    sendBuffer[6] = {0xD0};
    sendBuffer[7] = {0x07};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

  }
  rtde_control.moveL({blackLowPoint}, 0.5, 0.2);
  {
    sendBuffer[3] = {0x01};
    sendBuffer[6] = {0x00};
    sendBuffer[7] = {0x00};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

  }
  rtde_control.moveL({blackHighPoint}, 0.5, 0.2);
  //排到工作板第二排

  rtde_control.moveL({wellHighPoint2}, 0.5, 0.2);
  rtde_control.moveL({wellMidPoint2}, 0.5, 0.2);

  {
   sendBuffer[3] = {0x01};
    sendBuffer[6] = {0xD0};
    sendBuffer[7] = {0x07};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

  }

  //混合均匀
  rtde_control.moveL({wellLowPoint2}, 0.5, 0.2);

  {
    sendBuffer[3] = {0x01};
    sendBuffer[6] = {0x00};
    sendBuffer[7] = {0x00};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

    sendBuffer[3] = {0x01};
    sendBuffer[6] = {0xD0};
    sendBuffer[7] = {0x07};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

    sendBuffer[3] = {0x01};
    sendBuffer[6] = {0x00};
    sendBuffer[7] = {0x00};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

    sendBuffer[3] = {0x01};
    sendBuffer[6] = {0xD0};
    sendBuffer[7] = {0x07};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

      sendBuffer[3] = {0x01};
    sendBuffer[6] = {0x00};
    sendBuffer[7] = {0x00};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

    sendBuffer[3] = {0x01};
    sendBuffer[6] = {0xD0};
    sendBuffer[7] = {0x07};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

  }

  rtde_control.moveL({wellHighPoint2}, 0.5, 0.2);
  //扔掉吸头

  rtde_control.moveL({trashPoint}, 0.5, 0.2);

 {
    sendBuffer[3] = {0x02};
    sendBuffer[6] = {0xD0};
    sendBuffer[7] = {0x07};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

sendBuffer[3] = {0x02};
    sendBuffer[6] = {0x00};
    sendBuffer[7] = {0x00};
    checkSum(sendBuffer);
    serialPort.write_some(boost::asio::buffer(sendBuffer, 9));
    std::this_thread::sleep_for(std::chrono::milliseconds(5000));

  }

  //回到初始点
  rtde_control.moveL(initialPoint, 0.5, 0.2);

  //*****************************************************************************************************

  //****实验完成:)

  std::cout << "倍比稀释实验完成：）";

  //****************************************支线任务完成！************************************************//

  return 0;
}


text:
//
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/vinniefalco/http_proto
//

#ifndef BOOST_URL_DETAIL_COPIED_STRINGS_IPP
#define BOOST_URL_DETAIL_COPIED_STRINGS_IPP

#include <boost/url/detail/copied_strings.hpp>
#include <functional>

namespace boost {
namespace urls {
namespace detail {

bool
basic_copied_strings::
is_overlapping(
    string_view s) const noexcept
{
    auto const b1 = s_.data();
    auto const e1 = b1 + s_.size();
    auto const b2 = s.data();
    auto const e2 = b2 + s.size();
    auto const less_equal =
        std::less_equal<char const*>();
    if(less_equal(e1, b2))
        return false;
    if(less_equal(e2, b1))
        return false;
    return true;
}

basic_copied_strings::
~basic_copied_strings()
{
    while(dynamic_list_)
    {
        auto p = dynamic_list_;
        dynamic_list_ =
            dynamic_list_->next;
        delete[] p;
    }
}

basic_copied_strings::
basic_copied_strings(
    string_view s,
    char* local_buf,
    std::size_t local_size) noexcept
    : s_(s)
    , local_buf_(local_buf)
    , local_remain_(local_size)
{
}

string_view
basic_copied_strings::
maybe_copy(
    string_view s)
{
    if(! is_overlapping(s))
        return s;
    if(local_remain_ >= s.size())
    {
        std::memcpy(local_buf_,
            s.data(), s.size());
        s = string_view(
            local_buf_, s.size());
        local_buf_ += s.size();
        local_remain_ -= s.size();
        return s;
    }
    auto const n =
        sizeof(dynamic_buf);
    auto p = new dynamic_buf[1 +
        sizeof(n) * ((s.size() +
            sizeof(n) - 1) /
                sizeof(n))];
    std::memcpy(p + 1,
        s.data(), s.size());
    s = string_view(reinterpret_cast<
        char const*>(p + 1), s.size());
    p->next = dynamic_list_;
    dynamic_list_ = p;
    return s;
}

} // detail
} // urls
} // boost

#endif

ext: ipp

max_stars_repo_name: vgrigoriu/url

max_issues_repo_name: vgrigoriu/url

max_forks_repo_name: vgrigoriu/url


text:
//          Copyright Oliver Kowalke 2009.
// Distributed under the Boost Software License, Version 1.0.
//    (See accompanying file LICENSE_1_0.txt or copy at
//          http://www.boost.org/LICENSE_1_0.txt)

#ifndef BOOST_COROUTINES_DETAIL_STACK_ALLOCATOR_H
#define BOOST_COROUTINES_DETAIL_STACK_ALLOCATOR_H

#include <cstddef>

#include <boost/config.hpp>

#include <boost/context/detail/config.hpp>
#include <boost/coroutine/detail/segmented_stack_allocator.hpp>
#include <boost/coroutine/detail/standard_stack_allocator.hpp>

#ifdef BOOST_HAS_ABI_HEADERS
#  include BOOST_ABI_PREFIX
#endif

namespace boost {
namespace coroutines {

#if defined(BOOST_USE_SEGMENTED_STACKS)
typedef detail::segmented_stack_allocator   stack_allocator;
#else
typedef detail::standard_stack_allocator    stack_allocator;
#endif

}}

#ifdef BOOST_HAS_ABI_HEADERS
#  include BOOST_ABI_SUFFIX
#endif

#endif // BOOST_COROUTINES_DETAIL_STACK_ALLOCATOR_H

ext: hpp

max_stars_repo_name: ballisticwhisper/boost

max_issues_repo_name: ballisticwhisper/boost

max_forks_repo_name: ballisticwhisper/boost


text:
//  (C) Copyright John Maddock 2005.
//  Use, modification and distribution are subject to the
//  Boost Software License, Version 1.0. (See accompanying file
//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#ifdef TEST_STD_HEADERS
#include <functional>
#else
#include <boost/tr1/functional.hpp>
#endif

#include <boost/static_assert.hpp>
#include <boost/type_traits/is_same.hpp>
#define NO_INHERT_TEST
#include "verify_functor.hpp"

struct expected_result
{
   expected_result(){}
};

struct test
{
   expected_result field;
   expected_result nullary();
   expected_result nullary_c()const;
   expected_result nullary_v()volatile;
   expected_result nullary_cv()const volatile;
   expected_result unary(int);
   expected_result unary_c(int)const;
   expected_result unary_v(int)volatile;
   expected_result unary_cv(int)const volatile;
};

int main()
{
   verify_field_functor(std::tr1::mem_fn(&test::field), std::unary_function<test const*, const expected_result&>());
   verify_field_functor(std::tr1::mem_fn(&test::field), std::unary_function<test*, expected_result&>());
   verify_unary_functor(std::tr1::mem_fn(&test::nullary), std::unary_function<test*, expected_result>());
   verify_unary_functor(std::tr1::mem_fn(&test::nullary_c), std::unary_function<test const*, expected_result>());
   //verify_unary_functor(std::tr1::mem_fn(&test::nullary_v), std::unary_function<test volatile*, expected_result>());
   //verify_unary_functor(std::tr1::mem_fn(&test::nullary_cv), std::unary_function<test const volatile*, expected_result>());

   verify_binary_functor(std::tr1::mem_fn(&test::unary), std::binary_function<test*, int, expected_result>());
   verify_binary_functor(std::tr1::mem_fn(&test::unary_c), std::binary_function<test const*, int, expected_result>());
   //verify_binary_functor(std::tr1::mem_fn(&test::unary_v), std::binary_function<test volatile*, int, expected_result>());
   //verify_binary_functor(std::tr1::mem_fn(&test::unary_cv), std::binary_function<test const volatile*, int, expected_result>());
   return 0;
}

ext: cpp

max_stars_repo_name: lijgame/boost


text:
/* Copyright 2016-2017 Joaquin M Lopez Munoz.
 * Distributed under the Boost Software License, Version 1.0.
 * (See accompanying file LICENSE_1_0.txt or copy at
 * http://www.boost.org/LICENSE_1_0.txt)
 *
 * See http://www.boost.org/libs/poly_collection for library home page.
 */

/* basic usage of boost::function_collection */

#include <boost/poly_collection/function_collection.hpp>
#include <functional>
#include <memory>
#include <random>
#include <vector>
#include "rolegame.hpp"

int main()
{
//[basic_function_1
  std::vector<std::unique_ptr<sprite>> sprs;
  std::vector<std::string>             msgs;
  std::vector<window>                  wnds;
//]

  // populate sprs
  std::mt19937                 gen{92748}; // some arbitrary random seed
  std::discrete_distribution<> rnd{{1,1,1}};
  for(int i=0;i<4;++i){        // assign each type with 1/3 probability
    switch(rnd(gen)){
      case 0: sprs.push_back(std::make_unique<warrior>(i));;break;
      case 1: sprs.push_back(std::make_unique<juggernaut>(i));break;
      case 2: sprs.push_back(std::make_unique<goblin>(i));break;
    }
  }

  // populate msgs
  msgs.push_back("\"stamina: 10,000\"");
  msgs.push_back("\"game over\"");

  // populate wnds
  wnds.emplace_back("pop-up 1");
  wnds.emplace_back("pop-up 2");

//[basic_function_2
//=  #include <boost/poly_collection/function_collection.hpp>
//=  ...
//=
  // function signature accepting std::ostream& and returning nothing
  using render_callback=void(std::ostream&);

  boost::function_collection<render_callback> c;
//]

//[basic_function_3
//<-
  auto render_sprite=[](const sprite& s){
//->
//=  auto render_sprite(const sprite& s){
    return [&](std::ostream& os){s.render(os);};
  }/*<-*/;/*->*/

//<-
  auto render_message=[](const std::string& m){
//->
//=  auto render_message(const std::string& m){
    return [&](std::ostream& os){os<<m;};
  }/*<-*/;/*->*/

//<-
  auto render_window=[](const window& w){
//->
//=  auto render_window(const window& w){
    return [&](std::ostream& os){w.display(os);};
  }/*<-*/;/*->*/
//=  ...
//=
  for(const auto& ps:sprs)c.insert(render_sprite(*ps));
  for(const auto& m:msgs)c.insert(render_message(m));
  for(const auto& w:wnds)c.insert(render_window(w));
//]

//[basic_function_4
  const char* comma="";
  for(const auto& cbk:c){
    std::cout<<comma;
    cbk(std::cout);
    comma=",";
  }
  std::cout<<"\n";
//]

//[basic_function_5
  auto cbk=*c.begin();
  cbk(std::cout); // renders first element to std::cout
  std::function<render_callback> f=cbk;
  f(std::cout);   // exactly the same
//]

//[basic_function_6
//=  *c.begin()=render_message("last minute message"); // compile-time error
//]
}


text:
/**
 * Autogenerated by Thrift Compiler (0.9.0)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
#include <netinet/in.h>
#include <boost/shared_ptr.hpp>
#include <boost/chrono.hpp>
#include "boost/config/user.hpp"
#include "boost/thread.hpp"

#include "SimpleDelay.h"
#include "SimpleDelay.tcc"

#include <thrift/protocol/TBinaryProtocol.h>
#include <thrift/transport/TBufferTransports.h>
#include <thrift/transport/TSocket.h>

#include <iostream>
#include <fstream>

using namespace ::apache::thrift;
using namespace ::apache::thrift::protocol;
using namespace ::apache::thrift::transport;

static boost::thread thread1, thread2, thread3, thread4;
boost::chrono::duration<double> duplicateArray[40000];
static int run = 0;
static uint32_t data_size = 0;

void* executeThread(SimpleDelayClient &client, int arrayPos)
{
    const char* const METHOD_NAME = "executeThread";
    int count = 0;

    // Wait until start.
    while(!run)
    {
        boost::this_thread::sleep(boost::posix_time::microseconds(200));
    }

    for(; count < 10000; ++count)
    {
        Estructura es, ret;
        es.long1 = count;
        es.long2 = count*2;
        es.string1 = "Esto es una prueba para el test de performance rpcdds vs thrift vs rpcdds";
        for(int i = 0; i < data_size; ++i)
            es.prueba.push_back(i);

        boost::chrono::system_clock::time_point call_start = boost::chrono::system_clock::now();
        client.duplicate(ret, es);
        duplicateArray[arrayPos++] = boost::chrono::system_clock::now() - call_start;
    }

    return NULL;
}

int main(int argc, char** argv)
{
    boost::chrono::duration<double> program_seconds;

    if(argc == 3)
    {
        uint16_t ip[4];

        // Check that the parameter is a IP address.
        if(sscanf(argv[1], "%hu.%hu.%hu.%hu", &ip[0], &ip[1], &ip[2], &ip[3]) == 4)
        {
            if(sscanf(argv[2], "%u", &data_size) == 1)
            {
                boost::shared_ptr<TSocket> socket1(new TSocket(argv[1], 9090));
                boost::shared_ptr<TBufferedTransport> transport1(new TBufferedTransport(socket1));
                boost::shared_ptr<TBinaryProtocol> protocol1(new TBinaryProtocol(transport1));
                SimpleDelayClient client1(protocol1);
                boost::shared_ptr<TSocket> socket2(new TSocket(argv[1], 9090));
                boost::shared_ptr<TBufferedTransport> transport2(new TBufferedTransport(socket2));
                boost::shared_ptr<TBinaryProtocol> protocol2(new TBinaryProtocol(transport2));
                SimpleDelayClient client2(protocol2);
                boost::shared_ptr<TSocket> socket3(new TSocket(argv[1], 9090));
                boost::shared_ptr<TBufferedTransport> transport3(new TBufferedTransport(socket3));
                boost::shared_ptr<TBinaryProtocol> protocol3(new TBinaryProtocol(transport3));
                SimpleDelayClient client3(protocol3);
                boost::shared_ptr<TSocket> socket4(new TSocket(argv[1], 9090));
                boost::shared_ptr<TBufferedTransport> transport4(new TBufferedTransport(socket4));
                boost::shared_ptr<TBinaryProtocol> protocol4(new TBinaryProtocol(transport4));
                SimpleDelayClient client4(protocol4);

                try
                {
                    transport1->open();
                    transport2->open();
                    transport3->open();
                    transport4->open();

                    thread1 = boost::thread(executeThread, client1, 0);
                    thread2 = boost::thread(executeThread, client2, 10000);
                    thread3 = boost::thread(executeThread, client3, 20000);
                    thread4 = boost::thread(executeThread, client4, 30000);

                    run = 1;

                    boost::chrono::system_clock::time_point program_start = boost::chrono::system_clock::now();

                    thread1.join();
                    thread2.join();
                    thread3.join();
                    thread4.join();
                    run = 0;

                    program_seconds = boost::chrono::system_clock::now() - program_start;

                    // Print total execution time.
                    std::cout << "Program execution in " << program_seconds.count() << " seconds." << std::endl;

                    // Calcular latencia media y el que más tarda.
                    boost::chrono::duration<double> max_dur = duplicateArray[0];
                    int max_pos = 0;
                    boost::chrono::duration<double> min_dur = duplicateArray[0];
                    int min_pos = 0;
                    boost::chrono::duration<double> suma_dur = duplicateArray[0];

                    for(int count = 1; count < 40000; ++count)
                    {
                        if(duplicateArray[count] > max_dur)
                        {
                            max_dur = duplicateArray[count];
                            max_pos = count;
                        }

                        if(duplicateArray[count] < min_dur)
                        {
                            min_dur = duplicateArray[count];
                            min_pos = count;
                        }

                        suma_dur = suma_dur + duplicateArray[count];
                    }

                    std::sort(duplicateArray, duplicateArray + 40000);

                    std::cout << "The faster call was " << min_pos << " with " << min_dur << std::endl;
                    std::cout << "The slowest call was " << max_pos << " with " << max_dur << std::endl;
                    std::cout << "The latency average was " << suma_dur / 40000 << std::endl;
                    std::cout << "The 20000th value was " << duplicateArray[20000] << std::endl;

                    // Guardar datos en ficheros.
                    std::ofstream file;
                    file.open("clientes.txt", std::ios::app);
                    file << min_dur << " " << max_dur << " " << suma_dur/40000 << " " << duplicateArray[20000] << std::endl;
                    file.close();

                    transport1->close();
                    transport2->close();
                    transport3->close();
                    transport4->close();
                } catch (TException &tx) {
                    printf("ERROR: %s\n", tx.what());
                    std::cout << "Error: " << tx.what() << std::endl;
                }
            }
            else
            {
                std::cout << "Second parameter is not a valid data size." << std::endl;
            }
        }
        else
        {
            std::cout << "Parameter is not a valid IPv4 address." << std::endl;
        }
    }
    else
    {
        std::cout << "The server IP address is expected." << std::endl;
    }

    return 0;
}

max_stars_repo_name: romain-gimenez/RPC

max_issues_repo_name: romain-gimenez/RPC

max_forks_repo_name: romain-gimenez/RPC


text:
// Boost.Geometry (aka GGL, Generic Geometry Library)

// Copyright (c) 2007-2013 Barend Gehrels, Amsterdam, the Netherlands.

// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifndef BOOST_GEOMETRY_EXTENSIONS_STRATEGIES_BUFFER_DISTANCE_ASYMMETRIC_HPP
#define BOOST_GEOMETRY_EXTENSIONS_STRATEGIES_BUFFER_DISTANCE_ASYMMETRIC_HPP

// Buffer strategies

#include <boost/geometry/extensions/strategies/buffer_side.hpp>

namespace boost { namespace geometry
{

namespace strategy { namespace buffer
{

template<typename CoordinateType>
class distance_asymmetric
{
public :
    distance_asymmetric(CoordinateType const& left,
                CoordinateType const& right)
        : m_left(left)
        , m_right(right)
    {}

    template <typename Point>
    inline CoordinateType apply(Point const& , Point const& ,
                buffer_side_selector side)  const
    {
        return side == buffer_side_left ? m_left : m_right;
    }

    inline int factor() const
    {
        return m_left < 0 ? -1 : 1;
    }

private :
    CoordinateType m_left;
    CoordinateType m_right;
};

}} // namespace strategy::buffer

}} // namespace boost::geometry

#endif // BOOST_GEOMETRY_EXTENSIONS_STRATEGIES_BUFFER_DISTANCE_ASYMMETRIC_HPP