You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
941 B

7 years ago
​
4 years ago
​
​
​
​
7 years ago
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #include "basicEngine.h"
  2. // Constructor implementation
  3. basicEngine::basicEngine():basicObject(){
  4. m_bOWM = 0;
  5. m_bWM = 0;
  6. };
  7. // Destructor implementation
  8. basicEngine::~basicEngine(){
  9. m_mWMProtector.lock();
  10. m_mWMProtector.unlock();
  11. };
  12. bool basicEngine::setWM( uint8_t s, bool hard ){
  13. if( hard ){
  14. m_mWMProtector.lock();
  15. m_bOWM = m_bWM;
  16. m_bWM = s;
  17. m_mWMProtector.unlock();
  18. } else {
  19. if( m_mWMProtector.try_lock() ){
  20. m_bOWM = m_bWM;
  21. m_bWM = s;
  22. m_mWMProtector.unlock();
  23. } else return false;
  24. };
  25. return true;
  26. };
  27. uint8_t basicEngine::getWM( void ){
  28. uint8_t s;
  29. m_mWMProtector.lock();
  30. s = m_bWM;
  31. m_mWMProtector.unlock();
  32. return s;
  33. };
  34. uint8_t basicEngine::getOWM( void ){
  35. uint8_t s;
  36. m_mWMProtector.lock();
  37. s = m_bOWM;
  38. m_mWMProtector.unlock();
  39. return s;
  40. };
  41. void basicEngine::setBackOWM( void ){
  42. m_mWMProtector.lock();
  43. m_bWM = m_bOWM;
  44. m_mWMProtector.unlock();
  45. };