Exemple #1
0
 public function run()
 {
     $x = 0;
     while (1) {
         for ($i = 0; $i < 5; $i++) {
             //2*(x/a-ceil(1/2+x/a))
             $_x = $x + $i - 4;
             //$y=max( $_x-max($_x-1,0)*($_x) ,0)/2*100;
             //$y=max( $_x-2*max($_x-100,0) ,0);
             if (!($_x < 1 && $_x >= 0)) {
                 $y = 0;
             } else {
                 $y = abs(2 * ($_x / 1 - floor(1 / 2 + $_x / 1))) * 100;
             }
             $val = round($y);
             if ($this->devices[$i] instanceof Spot) {
                 $this->devices[$i]->setRGB($val, $val, $val);
             }
         }
         $this->dmx->send();
         $x += 0.05;
         if ($x > 5) {
             $x = 0;
         }
         usleep(30000);
     }
 }
Exemple #2
0
 function run()
 {
     foreach ($this->devices as $device) {
         $device->reset();
         $this->dmx->send();
     }
     foreach ($this->devices as $device) {
         if ($device instanceof Spot) {
             $device->addSignal(new Rectangel(0, 0.1, [1, 1, 1, 0, 0]));
         }
         if ($device instanceof Scanner) {
             $device->addSignal(new Rectangel(0, 0.1, [1, 1, 1, 0, 1]));
         }
     }
     $this->devices[0]->addSignal(new Ramp(0, 3, [0, 0, 1, 0, 0]));
     $this->devices[4]->addSignal(new Ramp(0, 3, [0, 0, 1, 0, 0]));
     $this->devices[1]->addSignal(new Ramp(2.5, 3, [0, 1, 0, 0, 0]));
     $this->devices[3]->addSignal(new Ramp(2.5, 3, [0, 1, 0, 0, 0]));
     $this->devices[2]->addSignal(new Ramp(5, 3, [1, 0, 0, 0, 0]));
     foreach ($this->devices as $spot) {
         $spot->addSignal(new Rectangel(8, 0.1, [1, 1, 1, 0, 0]));
         $spot->addSignal(new Random(8, 7, [1, 1, 1, 0, 0]));
     }
     $this->devices[0]->addSignal(new Ramp(15, 3, [0, 0, 1, 0, 0]));
     $this->devices[1]->addSignal(new Rectangel(15, 3, [0, 1, 0, 0, 0]));
     $this->devices[2]->addSignal(new Rectangel(15, 3, [1, 0, 0, 0, 0]));
     $this->devices[3]->addSignal(new Rectangel(15, 3, [0, 1, 0, 0, 0]));
     $this->devices[4]->addSignal(new Ramp(15, 3, [0, 0, 1, 0, 0]));
     $this->devices[0]->addSignal(new Rectangel(18, 0.5, [0, 0, 1, 0, 0]));
     $this->devices[1]->addSignal(new Rectangel(18.5, 0.5, [0, 1, 0, 0, 0]));
     $this->devices[2]->addSignal(new Rectangel(19, 0.5, [1, 0, 0, 0, 0]));
     $this->devices[3]->addSignal(new Rectangel(19.5, 0.5, [0, 1, 0, 0, 0]));
     $this->devices[4]->addSignal(new Rectangel(20, 0.5, [0, 0, 1, 0, 0]));
     $this->devices[4]->addSignal(new Rectangel(20, 0.5, [0, 0, 1, 0, 0]));
     $this->devices[3]->addSignal(new Rectangel(21, 0.5, [0, 1, 0, 0, 0]));
     $this->devices[2]->addSignal(new Rectangel(21.5, 0.5, [1, 0, 0, 0, 0]));
     $this->devices[1]->addSignal(new Rectangel(22, 0.5, [0, 1, 0, 0, 0]));
     $this->devices[0]->addSignal(new Rectangel(22.5, 0.5, [0, 0, 1, 0, 0]));
     foreach ($this->devices as $spot) {
         $spot->addSignal(new Random(23, 7, [1, 1, 1, 0, 0]));
     }
     $start = 0;
     $time = $start;
     while (1) {
         Logger::getInstance("prog.advanced")->debug("time: " . $time);
         $this->dmx->calcAll($time);
         $this->dmx->send();
         usleep(100000);
         $time += 0.1;
         if ($time > 30) {
             $time = $start;
         }
     }
 }
Exemple #3
0
 function run()
 {
     $this->dmx = new \DmxHttp\Controller\DMXPost();
     $this->dmx->addDevice(new Spot(6));
     $this->dmx->addDevice(new Spot(12));
     $this->dmx->addDevice(new Spot(18));
     $this->dmx->addDevice(new Spot(24));
     $this->dmx->addDevice(new Spot(30));
     $this->dmx->addDevice(new Spot(36));
     $this->dmx->addDevice(new Spot(42));
     $this->dmx->addDevice(new Spot(48));
     $this->dmx->addDevice(new Scanner(300));
     $this->dmx->addDevice(new Scanner(305));
     $this->dmx->addDevice(new Scanner(310));
     $this->dmx->addDevice(new Scanner(314));
     $console = new \Symfony\Component\Console\Application();
     $console->register("ls")->setDefinition(array())->setDescription("list devices")->setCode(function (\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output) {
         $table = new \Symfony\Component\Console\Helper\Table($output);
         $table->setHeaders(array('Start Channel', 'Type', 'status'));
         foreach ($this->dmx->getDevices() as $device) {
             $table->addRow([$device->getStartChannel(), get_class($device), '[' . implode(',', $device->getChannels()) . ']']);
         }
         $table->render();
     });
     $console->register("run")->setDefinition(array(new InputArgument('device', InputArgument::REQUIRED, 'start channel of a device'), new InputArgument('method', InputArgument::REQUIRED, 'method'), new InputArgument('args', InputArgument::IS_ARRAY, 'arguments')))->setDescription("set command")->setCode(function (InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output) {
         $device = null;
         foreach ($this->dmx->getDevices() as $_device) {
             if ($_device->getStartChannel() == $input->getArgument("device")) {
                 $device = $_device;
                 break;
             }
         }
         if ($device === null) {
             $output->writeln("<error>can't find device</error>");
             return 1;
         }
         $method = $input->getArgument("method");
         $args = $input->getArgument("args");
         call_user_func_array([$device, $method], $args);
         $this->dmx->send();
     });
     $console->run();
 }