1 <?php // php pages made with phpMyBuilder <http://kyber.dk/phpMyBuilder> ?>
5 // CSIRO Manufacturing Science and Technology, Preston Lab
7 // doedit page (hymod_bddb / boards)
11 pg_head("$bddb_label - Board Registration Results");
13 if (($serno=intval($serno)) != 0)
14 die("serial number must not be set ($serno) when Creating!");
16 $query="update boards set";
18 list($y, $m, $d) = split("-", $date);
19 if (!checkdate($m, $d, $y) || $y < 1999)
20 die("date is invalid (input '$date', yyyy-mm-dd '$y-$m-$d')");
21 $query.=" date='$date'";
24 if (strlen($batch) > 32)
25 die("batch field too long (>32)");
26 $query.=", batch='$batch'";
29 if (!in_array($type, $type_vals))
30 die("Invalid type ($type) specified");
31 $query.=", type='$type'";
33 if (($rev = intval($rev)) <= 0 || $rev > 255)
34 die("Revision number is invalid ($rev)");
35 $query.=sprintf(", rev=%d", $rev);
37 $query.=gather_enum_multi_query("sdram", 4);
39 $query.=gather_enum_multi_query("flash", 4);
41 $query.=gather_enum_multi_query("zbt", 16);
43 $query.=gather_enum_multi_query("xlxtyp", 4);
44 $nxlx = count_enum_multi("xlxtyp", 4);
46 $query.=gather_enum_multi_query("xlxspd", 4);
47 if (count_enum_multi("xlxspd", 4) != $nxlx)
48 die("number of xilinx speeds not same as number of types");
50 $query.=gather_enum_multi_query("xlxtmp", 4);
51 if (count_enum_multi("xlxtmp", 4) != $nxlx)
52 die("number of xilinx temps. not same as number of types");
54 $query.=gather_enum_multi_query("xlxgrd", 4);
55 if (count_enum_multi("xlxgrd", 4) != $nxlx)
56 die("number of xilinx grades not same as number of types");
60 die("can't specify cpu speed if there is no cpu");
62 die("can't specify cpm speed if there is no cpu");
64 die("can't specify bus speed if there is no cpu");
67 $query.=", cputyp='$cputyp'";
69 die("must specify cpu speed if cpu type is defined");
70 $query.=", cpuspd='$cpuspd'";
72 die("must specify cpm speed if cpu type is defined");
73 $query.=", cpmspd='$cpmspd'";
75 die("must specify bus speed if cpu type is defined");
76 $query.=", busspd='$busspd'";
79 if (($hschin = intval($hschin)) < 0 || $hschin > 4)
80 die("Invalid number of hs input chans ($hschin)");
81 if (($hschout = intval($hschout)) < 0 || $hschout > 4)
82 die("Invalid number of hs output chans ($hschout)");
85 die("number of high-speed input channels must be zero"
86 . " if high-speed chip is not present");
88 die("number of high-speed output channels must be zero"
89 . " if high-speed chip is not present");
92 $query.=", hstype='$hstype'";
93 $query.=", hschin='$hschin'";
94 $query.=", hschout='$hschout'";
96 // echo "final query = '$query'<br>\n";
98 $quant = intval($quant);
99 if ($quant <= 0) $quant = 1;
107 while ($quant-- > 0) {
109 mysql_query("insert into boards (serno) values (null)");
111 $sqlerr = mysql_error();
115 $serno = mysql_insert_id();
117 $sqlerr = "couldn't allocate new serial number";
121 mysql_query($query . " where serno=$serno");
123 $sqlerr = mysql_error();
127 array_push($sernos, $serno);
131 $ethaddr = gen_eth_addr($serno);
133 mysql_query("update boards set ethaddr='$ethaddr'" .
134 " where serno=$serno");
136 $sqlerr = mysql_error();
138 array_push($ethaddrs,
139 "<font color=#ff0000><b>" .
145 array_push($ethaddrs, $ethaddr);
149 $nsernos = count($sernos);
153 write_eeprom_cfg_file();
155 echo "<font size=+2>\n";
157 echo "\t\tThe following board serial numbers were"
158 . " successfully allocated";
160 echo " (but with $numerrs cfg file error" .
161 ($numerrs > 1 ? "s" : "") . ")";
167 echo "<table align=center width=\"100%\">\n";
169 echo "\t<th>Serial Number</th>\n";
171 echo "\t<th>Cfg File Errs</th>\n";
173 echo "\t<th>Ethernet Address</th>\n";
176 for ($i = 0; $i < $nsernos; $i++) {
178 $serno = sprintf("%010d", $sernos[$i]);
182 echo "\t<td align=center><font size=+2>" .
183 "<b>$serno</b></font></td>\n";
186 if (($errstr = $cfgerrs[$i]) == '')
188 echo "\t<td align=center>" .
189 "<font size=+2 color=#ff0000><b>" .
191 "</b></font></td>\n";
195 echo "\t<td align=center>" .
196 "<font size=+2 color=#00ff00><b>" .
198 "</b></font></td>\n";
208 echo "\t<font size=+4>\n";
210 echo "\t\t\tThe following SQL error was encountered:\n";
212 echo "\t\t<center>\n";
213 printf("\t\t\t<b>%s</b>\n", $sqlerr);
214 echo "\t\t</center>\n";
220 <table align=center width="100%">
222 <td align=center><a href="browse.php">Go to Browse</a></td>
223 <td align=center><a href="index.php">Back to Start</a></td>