our $specDir = '../specs';
my $setupFileName = "testsetup.xml";
-my $setupFile = $setupDir.$setupFileName;
+my $setupFile = $setupDir."/".$setupFileName;
# the file that tells me what fields should be printed in the quick edit area
# for each sensor
#### globals:
my $quickEditMaskTree;
+my $setupTree;
#######################
##################################
#### Subs
##################################
+
+sub parse_setupFile {
+ my $parser = XML::LibXML->new();
+ unless( -e $setupFile) {
+ die "setup file $setupFile does not exist!\n";
+ }
+ $setupTree = $parser->parse_file($setupFile);
+}
sub parse_quickEditMaskFile {
$quickEditMaskTree = $parser->parse_file($quickEditMaskFile);
}
-sub print_quickEditArea {
-
- unless(defined($quickEditMaskTree)) {
- parse_quickEditMaskFile();
- }
-
- print "<table>";
- my @fields = $quickEditMaskTree->findnodes("/MAPS/register/field");
- for my $field (@fields) {
- print "<tr><td>";
- print $field->findvalue("./\@name");
- print "</td></tr>";
-
-
- }
- print "</table>";
- print "print_registers();",br;
- parseConfigAndSpec("0.xml");
- integrateAncestry();
- print_registers(getConfigFile());
-
-}
sub init_html{
print "<div id='quickEditArea'>";
-print_quickEditArea();
+print_quickEditArea("0.xml");
print "</div>";
+print_setupStructure();
print end_html;
+sub print_setupStructure {
+ unless(defined($setupTree)) {
+ parse_setupFile();
+ }
+ my $setup = $setupTree->findnodes("/DetectorSetup")->shift();
+ unless(defined($setup)) { die "did not find DetectorSetup node in setup file!\n";}
+ my $setupDesc = $setup->findvalue("./description");
+ my $setupName = $setup->findvalue("./\@name");
+ print h2("Setup: $setupName");
+ print "<p>description: $setupDesc</p>";
+
+ my @controllers = $setup->findnodes("./controller");
+ unless(scalar(@controllers) > 0) { die "no controllers in setup file!\n";}
+ for my $controller (@controllers) {
+ my $controllerName = $controller->findvalue("./\@name");
+ my $controllerAddress = $controller->findvalue("./\@address");
+ my $controllerId = $controller->findvalue("./\@id");
+ print h3("Controller name:$controllerName id:$controllerId address:$controllerAddress");
+
+ my @chains = $controller->findnodes("./chain");
+ unless(scalar(@chains)>0) {die "no chains attached to controller $controllerName\n";}
+
+ for my $chain (@chains) {
+ my $chainName = $chain->findvalue("./\@name");
+ my $chainId = $chain->findvalue("./\@id");
+ print h4("Chain name:$chainName id:$chainId");
+
+ my @sensors = $chain->findnodes("./sensor");
+ unless(scalar(@sensors)>0) { die "no sensors attached to chain $chainName\n";}
+ for my $sensor (@sensors) {
+
+ my $sensorId = $sensor->findvalue("./\@id");
+ my $sensorName = $sensor->findvalue("./\@name");
+ my $sensorConfig = $sensor->findvalue("./\@config");
+ my $sensorEnabled = $sensor->findvalue("./\@enabled");
+ my $sensorSerial = $sensor->findvalue("./\@serial");
+ my $sensorPosition = $sensor->findnodes("./position")->shift();
+ my $sensorDescription = $sensor->findvalue("./description");
+
+ print h5("Sensor name:$sensorName id:$sensorId");
+ print "<p>description: $sensorDescription</p>";
+ print_sensorArea($sensor);
+ }
+
+ }
+
+ }
+
+}
sub report_param {
#### html output subs ###########
+
+sub print_sensorArea {
+
+ my $sensor = $_[0];
+ # this is an xml object that contains the sensor node
+ # from the setup file
+ my $sensorId = $sensor->findvalue("./\@id");
+ my $sensorName = $sensor->findvalue("./\@name");
+ my $sensorConfig = $sensor->findvalue("./\@config");
+ my $sensorEnabled = $sensor->findvalue("./\@enabled");
+ my $sensorSerial = $sensor->findvalue("./\@serial");
+ my $sensorPosition = $sensor->findnodes("./position")->shift();
+ my $sensorDescription = $sensor->findvalue("./description");
+
+ my $sensorAreaId = $sensorId;
+ print "<div class='sensorAreaDiv' id='".$sensorAreaId."'>";
+ print "<table class='sensorAreaTable'>";
+ print "<tr>";
+ print "<td colspan=2>$sensorName</td>";
+ print "</tr>";
+ print "<tr>";
+ print "<td>blah</td><td>";
+ print_quickEditArea($sensorConfig);
+ print "</td>";
+ print "</tr>";
+ print "<table>";
+ print "</div>";
+
+
+}
+# description the block that is printed for each sensor,
+# containing the preview plot and the quick edit area
+
+
+sub print_quickEditArea {
+
+ my $argumentConfigFile = $_[0];
+
+ unless(defined($quickEditMaskTree)) {
+ parse_quickEditMaskFile();
+ }
+
+# print "<table>";
+# my @fields = $quickEditMaskTree->findnodes("/MAPS/register/field");
+# for my $field (@fields) {
+# print "<tr><td>";
+# print $field->findvalue("./\@name");
+# print "</td></tr>";
+#
+#
+# }
+# print "</table>";
+# print "print_registers();",br;
+ parseConfigAndSpec($argumentConfigFile);
+ integrateAncestry();
+ print_registers(getConfigFile());
+
+
+}
+
+
sub print_registers {
my $configFile = getConfigFile();