Okay...since PHP5 works nicely with GPIB and my NI GPIB card...thought I give this one a new try (o;
A quick PHP hack drawing the spectrum of my CRTU-RU....
<?php
$string = "";
$image = "";
$u = ibfind("crtu");
ibpad($u, 20);
ibsad($u, 97);
ibwrt($u, "1;INITiate:SPECtrum");
ibwrt($u, "1;READ:ARRay:SPECtrum?");
while($r = ibrd($u, $string, 1000))
{
$count = ibcnt();
$image .= $string;
if($count < 1000)
break;
}
ibwrt($u, "*GTL");
$spectrum = explode(",", $image);
$min = 0;
$max = -1000;
foreach($spectrum as $value)
{
$point = 4 * number_format((float)$value, 5);
$rf[] = $point;
if($min > $point)
$min = $point;
if($point > $max)
$max = $point;
}
// echo "Min: " . $min . "\n";
// echo "Max: " . $max . "\n";
$im = @ImageCreate (560, 512);
$background_color = ImageColorAllocate ($im, 234, 234, 234);
$graph_color = ImageColorAllocate ($im,25,25,25);
$x1 = 0;
$x2 = 0;
$y1 = 0;
foreach($rf as $pixel)
{
$y2 = 150 - $pixel;
if($x2)
{
imageline ($im, $x1, $y1, $x2, $y2, $graph_color);
// echo "<pre>Drawing from " . $x1 . ":" . $y1 . " to " . $x2 . ":" . $y2 . "</pre>";
}
$y1 = $y2;
$x1 = $x2;
$x2++;
}
header ("Content-type: image/jpg");
ImageJPEG ($im);
?>
Much to improve though...but as a first start not bad...takes around 300msec to render the image: