Example #1
0
 /**
  *
  * @access public
  */
 public function bienvenidaSistema($f = false)
 {
     $this->ocultarMenu();
     system_class::log_message("CMD bienvenidaSistema!!!!! " . var_dump($f, 1));
     if ($f) {
         $this->setComando("BIENVENIDO:ON");
     } else {
         $this->setComando("BIENVENIDO");
     }
 }
Example #2
0
 function server_socket()
 {
     //---- Start Socket creation for PHP Socket Server -------------------------------------
     system_class::log_message("socket server hasi");
     if (($master = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) < 0) {
         system_class::log_message("socket_create() failed, reason: " . socket_strerror($master));
     }
     $this->master_socket = $master;
     system_class::log_message("create_socket");
     socket_set_option($master, SOL_SOCKET, SO_REUSEADDR, 1);
     if (($ret = socket_bind($master, ADDRESS, PORT)) < 0) {
         system_class::log_message("socket_bind() failed, reason: " . socket_strerror($ret));
     }
     system_class::log_message("create_bind");
     if (($ret = socket_listen($master, 5)) < 0) {
         system_class::log_message("socket_listen() failed, reason: " . socket_strerror($ret));
     }
     system_class::log_message("listen");
     self::$read_sockets = array($master);
     system_class::log_message("master:: " . print_r($master, 1));
     //---- Create Persistent Loop to continuously handle incoming socket messages ---------------------
     while (true) {
         $changed_sockets = self::$read_sockets;
         $num_changed_sockets = socket_select($changed_sockets, $write = NULL, $except = NULL, NULL);
         system_class::log_message("IREKIAK:" . join(self::$read_sockets, ',') . " ALDATUAK:" . join($changed_sockets, ',') . "({$num_changed_sockets})");
         if ($num_changed_sockets === false) {
             system_class::log_message("-------->ERROREA SOCKET-EAN<--------------");
         }
         if (empty(self::$read_sockets)) {
             system_class::log_message("SOCKETA HUTSIK DAGO");
             exit;
         }
         foreach ($changed_sockets as $socket) {
             $this->changed_socket = $socket;
             if ($socket == $master) {
                 //flash konexio berria
                 if (($client = socket_accept($master)) < 0) {
                     system_class::log_message("socket_accept() failed: reason: " . socket_strerror($msgsock));
                     continue;
                 } else {
                     array_push(self::$read_sockets, $client);
                     array_push(self::$flash_sockets, $client);
                     self::$last_client = $client;
                 }
             } else {
                 //flash-etik idazten dute
                 $bytes = socket_recv($socket, $buffer, 4096, 0);
                 if (trim($bytes) == 0) {
                     $this->quit_socket($socket);
                     continue;
                 }
                 if ($buffer == 'bye') {
                     $this->quit_socket($socket);
                     continue;
                 } else {
                     system_class::log_message("\n\n @@@jaso cmd berria====>" . trim($buffer) . "<=====\n");
                     $arr_buf = explode('>', $buffer);
                     foreach ($arr_buf as $buf) {
                         $buf = trim($buf);
                         if (!empty($buf)) {
                             $buf = $buf . '>';
                             system_class::log_message("FLASH CMD: " . trim($buf));
                             $this->flash_cmd($socket, $buf);
                         }
                     }
                 }
             }
         }
     }
 }
Example #3
0
 /**
  *
  *
  * @param int id
  * @return string
  * @access public
  */
 public function getComando($id)
 {
     system_class::log_message("MIC id:" . $id . "  cMD:::" . self::$COMANDOS[$id]);
     return self::$COMANDOS[$id];
 }
Example #4
0
 /**
  * Metodo para desactivar el sonido del canal ($canal) y fader ($fader) indicados como parametros
  *
  * Una vez hechos todos los cambios, los guardara en el archivo estadoDispositivos.php
  *
  * @access public
  * @link Properties::guardarEstado()
  * @param int $canal
  * @param int $fader
  */
 public function apagar($canal, $fader)
 {
     $fadernum = 63 + self::$fader[$fader];
     system_class::log_message("APAGAR MICRO:::: fader1:" . $fader . " fader2: " . self::$fader[$fader] . " canal: " . $canal . " fadernum " . $fadernum);
     $comando = $this->procesarComando("", array("canal" => $canal, "fader" => $fadernum, "volumen" => self::$VOLOFF));
     $this->guardarEstado();
     $this->enviarComando($comando);
 }
Example #5
0
 public function write1($comando)
 {
     $comando = $this->cabecera . $comando . "\r\n";
     $len = strlen($comando);
     $respuesta = trim($this->socket->read(300));
     $this->socket->writeLine($comando);
     if (strcmp($this->strDireccionIP, "192.168.0.130") == 0 && $this->intPuertoCom == 5) {
         echo "generador multiventanas\n";
     } else {
         if (strpos($comando, "4RS|S") > 0) {
             usleep(20000);
         } else {
             usleep($len * 100000);
         }
         //        sleep(ceil($len*0.0001) );
         $respuesta = trim($this->socket->read(100));
         $respuesta = trim($respuesta, "..");
         system_class::log_message("CMD ip:" . $this->strDireccionIP . ":" . $this->intPuerto . " COMANDO: " . trim($comando) . " respuesta: " . trim($respuesta));
         return $respuesta;
     }
 }