Guest User

main.cpp

a guest
Jul 17th, 2012
67
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "stdafx.h"
  2. #include "sensor.h"
  3. #include "driverControl.h"
  4. #include "driver.h"
  5.  
  6. int _tmain( int argc, TCHAR *argv[] )
  7. {
  8. Sensor sensor;
  9. sensor.initialize();
  10.  
  11. DriverControl driverControl;
  12. Driver driverA(1, TYPE_STD | SET_CH_A);
  13. Driver driverB(2, TYPE_STD | SET_CH_A);
  14. Driver driverC(3, TYPE_STD | SET_CH_A);
  15.  
  16. if(!driverControl.numModules()){
  17. std::cout << "No modules found at COM port 1\n";
  18. return 1;
  19. }
  20.  
  21. if((!driverA.setParameter()) || (!driverB.setParameter()) || (!driverC.setParameter())){
  22. std::cout << "Communication error.\n";
  23. LdcnShutdown();
  24. return 1;
  25. }
  26.  
  27. driverA.enable(STOP_SMOOTH | STP_ENABLE_AMP);
  28. driverB.enable(STOP_SMOOTH | STP_ENABLE_AMP);
  29. driverC.enable(STOP_SMOOTH | STP_ENABLE_AMP);
  30.  
  31. driverA.loadTraj(LOAD_SPEED | LOAD_ACC, 0, 100, 255, 0);
  32. driverB.loadTraj(LOAD_SPEED | LOAD_ACC, 0, 100, 255, 0);
  33. driverC.loadTraj(LOAD_SPEED | LOAD_ACC, 0, 100, 255, 0);
  34.  
  35. driverA.setGroup(1);
  36. driverB.setGroup(0);
  37. driverC.setGroup(0);
  38.  
  39. driverControl.startMotion();
  40.  
  41. int num = 0;
  42. while(num < 200)
  43. num++;
  44.  
  45. driverA.stopMotor(STOP_SMOOTH);
  46. driverB.stopMotor(STOP_SMOOTH);
  47. driverC.stopMotor(STOP_SMOOTH);
  48.  
  49. /* ok = ReadFile(hCom, buffer, BUFFSIZE, & bytesRead, NULL);
  50. for(int j = 0; j < 8; j++)
  51. buffer_string += buffer[j];
  52. buffer_value = (float)atof(buffer_string.c_str());
  53. while(buffer_value < stop + 5)
  54. {
  55. std::cout << buffer_value << std::endl;
  56. buffer_string.clear();
  57. ok = ReadFile(hCom, buffer, BUFFSIZE, & bytesRead, NULL);
  58. for(int j = 0; j < 8; j++)
  59. buffer_string += buffer[j];
  60. buffer_value = (float)atof(buffer_string.c_str());
  61. }*/
  62.  
  63. return 0;
  64. }
RAW Paste Data