From: Michael Wiebusch Date: Thu, 4 Jul 2013 13:27:45 +0000 (+0200) Subject: now checking if field values are in allowed range X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=be21111391e17e714ba6865cbb790c8028196ace;p=mvdsensorcontrol.git now checking if field values are in allowed range --- diff --git a/layout/jtageditor.css b/layout/jtageditor.css index b19854f..dd5b8e0 100644 --- a/layout/jtageditor.css +++ b/layout/jtageditor.css @@ -99,6 +99,11 @@ table.registers>tbody>tr>td:nth-child(2) { } +.fieldError +{ +background:red; +} + .fileLevel { background:#CCFFCC; diff --git a/xml_spielwiese/cgitest.pl b/xml_spielwiese/cgitest.pl index dd97f5a..227fa0f 100755 --- a/xml_spielwiese/cgitest.pl +++ b/xml_spielwiese/cgitest.pl @@ -3,9 +3,6 @@ print "Content-type: text/html\n\n"; # TODO # what happens when files are not writable? -# delete button -# field size information -# check for maximum value # DONE # do not include wrong type, different specfile @@ -14,6 +11,9 @@ print "Content-type: text/html\n\n"; # nested include graphic # cannot inherit from files with the wrong specification! # do not accept "..." as input file +# delete button +# field size information +# check for maximum value my $me = "cgitest.pl"; @@ -309,11 +309,13 @@ sub buildAncestry { # recursive my $xmlfile = $confDir . "/" . $xmlfileName; # check if all files in the ancestry really exist! - unless (-e $xmlfile) { + unless ( -e $xmlfile ) { print "

You are trying to include a file that does not exist

"; print "

"; - print "".$xmlfileName.""."->" + print "" + . $xmlfileName + . "" . "->" . join( "->", @ancestryList ) . "->" . $setfileName; print "

"; @@ -324,7 +326,6 @@ sub buildAncestry { # recursive return; } - my $xmltree; if ( $xmlfile eq $setfile ) { $xmltree = $settree; @@ -545,9 +546,9 @@ sub print_fileSelection { my $configFile = $_[0]; - print "

selected config file

"; + print "

selected config file

"; print "

"; - + print_fileSelector( $configFile, "fileSelector", "loadFile()" ); print ""; @@ -555,17 +556,23 @@ sub print_fileSelection { ""; print "

"; - - - print "

create new config file

"; + + print "

create new config file

"; print "

"; + print ""; + print ""; + print ""; + print ""; + print "
filenamebased on specification
"; print ""; + print ""; print_specSelector(); - print ""; - - print "

"; - + print "
"; + print +""; + print "
"; + print "

"; # print ""; # print ""; + if ( ( any2dec($fieldValue) < 0 ) + or ( any2dec($fieldValue) > $maxFieldVal ) ) + { + print ""; # just debug + } } print "
"; @@ -822,7 +829,14 @@ sub print_fields { my $isHeritageFrom = $field->findvalue("./\@isHeritageFrom") || ""; my $readOnlyFlag = 0; my $fieldValue = $field->findvalue("./\@value"); - my $fieldDescr = prepare_text( + my $fieldSize = + $spectree->findvalue( "/MAPS/register[\@name='" + . $registerName + . "']/field[\@name='" + . $fieldName + . "']/\@size" ) + || "n/a"; + my $fieldDescr = prepare_text( $spectree->findvalue( "/MAPS/register[\@name='" . $registerName @@ -833,6 +847,14 @@ sub print_fields { || "n/a" ); + my $maxFieldVal = 2**$fieldSize; + my $sizeInfo = + sprintf( + "Field contains %d bits, possible values: 0-%d (0x0-0x%x)\n\n", + $fieldSize, $maxFieldVal, $maxFieldVal ); + + $fieldDescr = $sizeInfo . $fieldDescr; + unless ( $isHeritageFrom eq "" ) { $fieldDescr = "Field was inherited from $isHeritageFrom\n\n" . $fieldDescr; @@ -881,6 +903,11 @@ EOF } } print "
!!!Above value not in allowed range!!!
"; @@ -914,6 +941,20 @@ sub read_input { %FORM; } +sub any2dec { # converts numeric expressions 0x, 0b or decimal to decimal + + my $argument = $_[0]; + + #print "any2dec input argument $argument\n"; + + if ( $argument =~ m/0[bxBX]/ ) { + return oct $argument; + } + else { + return $argument; + } +} + sub printJavaScripts { ####### javascript function land ################