Ejemplo n.º 1
0
 /**
  * Visual test:
  * - PUMP led should be on
  * - PUMP led should be off
  * - PUMP led should be on
  */
 public function testRelaisPump()
 {
     echo 'Pump - 9 - OFF' . PHP_EOL;
     $this->manager->publish(new PumpStateMessage(Pump::STATE_OFF), Log::TOPIC_PUMP_CURR_STATE);
     $this->manager->publish(new PumpStateMessage(Pump::STATE_ON), Log::TOPIC_PUMP_CURR_STATE);
     echo 'Pump - 9 - ON' . PHP_EOL;
     sleep(5);
     $this->manager->publish(new PumpStateMessage(Pump::STATE_OFF), Log::TOPIC_PUMP_CURR_STATE);
     echo 'Pump - 9 - OFF' . PHP_EOL;
 }
Ejemplo n.º 2
0
 public function testDashboard()
 {
     $this->manager->publish(new TemperatureMessage(1), Log::TOPIC_HLT_CURR_TEMP);
     $this->manager->publish(new TemperatureMessage(2), Log::TOPIC_MLT_CURR_TEMP);
     $this->manager->publish(new TemperatureMessage(3), Log::TOPIC_BLT_CURR_TEMP);
     $this->brewControlManager->setMashTemperature(4);
     $this->manager->publish(new PumpModeMessage(Pump::MODE_AUTOMATIC), Log::TOPIC_PUMP_CURR_MODE);
     usleep(500000);
     $this->manager->publish(new PumpModeMessage(Pump::MODE_MANUAL), Log::TOPIC_PUMP_CURR_MODE);
     usleep(500000);
     $this->manager->publish(new PumpStateMessage(Pump::STATE_ON), Log::TOPIC_PUMP_CURR_STATE);
     usleep(500000);
     $this->manager->publish(new PumpStateMessage(Pump::STATE_OFF), Log::TOPIC_PUMP_CURR_STATE);
     usleep(500000);
     $this->manager->publish(new PumpModeMessage(Pump::MODE_AUTOMATIC), Log::TOPIC_PUMP_CURR_MODE);
     usleep(500000);
     $this->manager->publish(new PumpModeMessage(Pump::MODE_MANUAL), Log::TOPIC_PUMP_CURR_MODE);
 }
Ejemplo n.º 3
0
 private function startReceiving()
 {
     $mlt = $this;
     // TODO: refactor want dit hoort niet in logic thuis, needs to be handled by 'consume' thread / process
     $callback = function (AMQPMessage $msg) use($mlt) {
         $topic = $msg->delivery_info['routing_key'];
         $value = $msg->body;
         $mlt->setCurrentTemperature($value);
         echo sprintf("Message received: %s: %s : %s", (new \DateTime())->format('H:i:s'), $topic, $value) . PHP_EOL;
     };
     $this->amqpManager->consume($callback, Log::TOPIC_MLT_CURR_TEMP);
 }
 /**
  * @param $title
  * @param $text
  * @return bool
  */
 public function dialog($title, $text, $identifier = null)
 {
     return $this->amqpManager->publish(new DialogMessage($title, $text, $identifier), self::ROUTE_BROADCAST_DIALOG);
 }
 /**
  * @param  string $value
  * @return bool
  */
 public function setPumpState($value)
 {
     return $this->amqpManager->publish(new PumpStateMessage($value), self::ROUTE_PUMP_SET_STATE);
 }
 public function testInvalidLogger()
 {
     $this->setExpectedException(get_class(new \PHPUnit_Framework_Error("", 0, "", 1)));
     $this->manager->setLogger(new \stdClass());
     $this->assertNotInstanceOf('Psr\\Log\\LoggerInterface', $this->manager->getLogger());
 }