TrafficLightRunner.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /**
  2. * Copyright (c) 2012 committers of YAKINDU and others.
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * http://www.eclipse.org/legal/epl-v10.html
  7. * Contributors:
  8. * m.muehlbrandt - initial API and implementation
  9. *
  10. */
  11. #include "TrafficLightRunner.h"
  12. TrafficLightRunner::TrafficLightRunner(TrafficLightWaiting *handle, int time_ms) :
  13. QObject() {
  14. this->handle = handle;
  15. timer = new QTimer(this);
  16. connect(timer, SIGNAL(timeout()), this, SLOT(runCycle()));
  17. timer->start(time_ms);
  18. }
  19. void TrafficLightRunner::runCycle() {
  20. trafficLightWaiting_runCycle(handle);
  21. emit cycleDone(handle);
  22. }
  23. void TrafficLightRunner::raisePedestrianRequest() {
  24. trafficLightWaitingIface_raise_pedestrianRequest(handle);
  25. }
  26. void TrafficLightRunner::raiseOnOff() {
  27. trafficLightWaitingIface_raise_onOff(handle);
  28. }
  29. TrafficLightRunner::~TrafficLightRunner() {
  30. timer->stop();
  31. delete timer;
  32. }