44 lines
1.5 KiB
PHP
44 lines
1.5 KiB
PHP
<?php namespace App\Console\Commands;
|
|
|
|
use App\Services\ArcoSimuladorService;
|
|
use Illuminate\Console\Command;
|
|
|
|
class SimularArcoReforma extends Command
|
|
{
|
|
protected $signature = 'arco:simular
|
|
{--min=5 : Tiempo mínimo de espera entre vehículos (segundos)}
|
|
{--max=30 : Tiempo máximo de espera entre vehículos (segundos)}
|
|
{--single : Simular solo un vehículo}';
|
|
|
|
protected $description = 'Simula vehículos pasando por el ARCO RFID de Reforma';
|
|
|
|
public function handle(ArcoSimuladorService $simulador): int
|
|
{
|
|
$min = (int) $this->option('min');
|
|
$max = (int) $this->option('max');
|
|
$single = $this->option('single');
|
|
|
|
if ($single) {
|
|
$this->info('Simulando paso de un vehículo...');
|
|
$resultado = $simulador->simularPasoVehiculo();
|
|
|
|
if ($resultado['success']) {
|
|
$this->info("Vehículo detectado: {$resultado['vehiculo']['placa']} - {$resultado['vehiculo']['marca']} {$resultado['vehiculo']['modelo']}");
|
|
$this->line(json_encode($resultado['deteccion'], JSON_PRETTY_PRINT));
|
|
} else {
|
|
$this->error($resultado['message']);
|
|
}
|
|
|
|
return Command::SUCCESS;
|
|
}
|
|
|
|
$this->info("Iniciando simulación continua del ARCO Reforma...");
|
|
$this->info("Tiempo de espera entre vehículos: {$min}-{$max} segundos");
|
|
$this->warn("Presiona Ctrl+C para detener la simulación");
|
|
|
|
$simulador->iniciarSimulacionContinua($min, $max);
|
|
|
|
return Command::SUCCESS;
|
|
}
|
|
}
|