// Paramètres du beagleprint (IP, user.pwd) $Beagleprint_IP = "xxx.xxx.xxx.xx"; $Beagleprint_user = "xxx"; $Beagleprint_pwd = "xxxx"; //Id des commandes du virtuel; $info_nomfichier = "xxx"; $info_progression = "xxx"; $info_timeleft = "xxx"; $info_timelefthuman = "xxx"; //Initialisation Payload pour avancement de l'impression //Cmd 318 $fields = [ 'pro' => 'get_prgresp', 'cmd' => 318, 'user' => $Beagleprint_user, 'pwd' => $Beagleprint_pwd ]; //$scenario->setLog($fields); $postdata = http_build_query($fields); $opts = array('http' => array( 'method' => 'POST', 'header' => 'Content-Type: application/json', 'content' => $postdata ) ); $context = stream_context_create($opts); $result = file_get_contents('http://' . $Beagleprint_IP . '/set3DPiCmd', false, $context); $scenario->setLog($result); //On décode le retour Json $arrayobj=json_decode($result,true); //On récupère les valeurs des champs $fileName=strval($arrayobj["file_name"]); $progress=intval($arrayobj["progress"]); $timeleft=intval($arrayobj["time_left"]); //conversion du timeleft (sec) en heure/minute $timelefthuman = gmdate("H:i:s",$timeleft); //Log $scenario->setLog($fileName); $scenario->setLog($progress); $scenario->setLog($timelefthuman); //On les mets dans les commandes du virtuel cmd::byId($info_nomfichier)->event($fileName); cmd::byId($info_progression)->event(($progress)); cmd::byId($info_timeleft)->event(($timeleft)); cmd::byId($info_timelefthuman)->event(($timelefthuman));