for ($i = 0; $i < sizeof($tl->servoKeys); $i++) { // пауза между фреймами $time = $tl->servoKeys[$i]; if ($time2 > 0) { usleep((int) (($time - $time2) * 1000)); } $time2 = $time; // установить сервы в нужные углы $arrPos = $tl->servoTimeline[$tl->servoKeys[$i]]; if ($arrPos["s2"] != '') { $str1 = makeServoCommand(array("s2" => $arrPos["s2"], "s3" => $arrPos["s3"], "s4" => $arrPos["s4"])); // send($str1); } if ($arrPos["s9"] != '') { $str2 = makeServoCommand(array("s9" => $arrPos["s9"], "s10" => $arrPos["s10"], "s11" => $arrPos["s11"])); send($str2); } //print_r($str1); //print_r($str2); //$binCommand .= makeServoCommandBin($arrPos);// либо в бинарном (в 3,5 раза меньше) } fclose($fp); print $lo; print "OK"; function send($str) { global $fp; print microtime(true) . " Send: "; for ($i = 0; $i < strlen($str); $i++) { fwrite($fp, substr($str, $i, 1));
$tl->calculateTimeLine(); $time = 0; $time2 = 0; $strCommand = ''; $pause = 0; for ($i = 0; $i < sizeof($tl->servoKeys); $i++) { // пауза между фреймами $time = $tl->servoKeys[$i]; if ($time > 0) { $pause = $time - $time2; } print "{$time}, {$time2}<br>"; $time2 = $time; // установить сервы в нужные углы $arrPos = $tl->servoTimeline[$tl->servoKeys[$i]]; $strCommand .= makeServoCommand($arrPos) . "\n"; // в обычном формате $strCommand .= "p{$pause};\n"; // //$binCommand .= makeServoCommandBin($arrPos);// в бинарном (в 3,5 раза меньше) } $fpc = fopen("commands.model", "w+"); fwrite($fpc, $strCommand); fclose($fpc); /* print strlen($strCommand)."<br>"; print strlen($binCommand)."<br>"; $cnt=0; $str="";