Commit 38ec77e4 authored by Christian Fibich's avatar Christian Fibich Committed by Stefan Tauner
Browse files

Switched UART order to front in download tool.

Set application name for Gnome
Only allow to select Fault Models actually present in HW in download tool.
Beautify run.
parent 38df28f2
......@@ -616,7 +616,16 @@ BEGIN {
ini_name => "UART",
default => "/dev/ttyUSB0",
gui_modes => [qw (manual auto random)],
order => 120,
order => 1,
},
HALT_ON_FAULT_DETECT => {
description => "Halt on detected fault",
ini_name => "HALT_ON_FAULT_DETECT",
default => 1,
type => 'boolean',
phases_opt => [qw(manual)],
gui_modes => [qw (auto random)],
order => 10,
},
NUM_TESTS => {
ini_name => "NUM_TESTS",
......@@ -640,15 +649,7 @@ BEGIN {
phases_opt => [qw(manual)],
gui_modes => [qw (auto)],
order => 12,
},
HALT_ON_FAULT_DETECT => {
description => "Halt on detected fault",
ini_name => "HALT_ON_FAULT_DETECT",
default => 1,
type => 'boolean',
phases_opt => [qw(manual)],
gui_modes => [qw (auto random)],
order => 10,
depends_on => "REPEAT",
},
HALT_ON_UART_ERROR => {
ini_name => "HALT_ON_UART_ERROR",
......
......@@ -86,7 +86,7 @@ sub new ($;$$) {
} else {
$fiji_settings_ref->{'design'} = {};
_set_defaults(DESIGNMAP, $fiji_settings_ref->{'design'}, $phase);
$fiji_settings_ref->{'fius'} = [];
$fiji_settings_ref->{'fius'} = [];
$fiji_settings_ref->{'filename'} = File::Spec->curdir();
}
......
......@@ -528,6 +528,7 @@ sub validate_value {
}
}
}
return 1;
}
......
......@@ -45,7 +45,6 @@ BEGIN {
use Test::Deep::NoTest;
use Clone qw(clone);
use File::Spec qw (file_name_is_absolute abs2rel splitpath catpath);
use base qw(Tk::Frame);
......@@ -75,7 +74,7 @@ sub Populate {
my $settings = delete $args->{'-settings'};
$self->{'change_indicator_ref'} = delete $args->{'-change_indicator_ref'};
$self->{'change_indicator_values'} = delete $args->{'-change_indicator_values'};
$self->{'documentation_path'} = delete $args->{'-documentation_path'};
$self->{'documentation_path'} = delete $args->{'-documentation_path'};
if (!defined($settings) || !blessed($settings) || !$settings->isa("FIJI::Settings")) {
$logger->error("Given settings are not of type FIJI::Settings. No way to report this back from the constructor...");
......@@ -170,8 +169,8 @@ sub settings {
return undef;
}
my $old_settings = $self->{'settings'};
$self->{'settings'} = $settings;
$self->{'original_settings'} = clone($settings);
$self->{'settings'} = $settings;
$self->{'original_settings'} = clone($settings);
$self->{'original_settings'}->{'fius'} = clone($settings->{'fius'});
# tk:trace for canvas update
......@@ -190,8 +189,8 @@ sub settings {
)->Show();
if ($rv eq "No") {
$logger->info("Using original settings");
$self->{'settings'} = $old_settings;
$self->{'original_settings'} = clone($old_settings);
$self->{'settings'} = $old_settings;
$self->{'original_settings'} = clone($old_settings);
$self->{'original_settings'}->{'fius'} = clone($old_settings->{'fius'});
# tk:trace for canvas update
......@@ -599,7 +598,7 @@ sub _populate_widget {
)->Show;
if (defined $val) {
my ($basevolume, $basedirs, $file) = File::Spec->splitpath($self->{'settings'}->{'filename'});
my $nv = File::Spec->abs2rel($val,File::Spec->catpath($basevolume,$basedirs));
my $nv = File::Spec->abs2rel($val, File::Spec->catpath($basevolume, $basedirs));
$logger->info("Setting $k to relative path $nv") if (File::Spec->file_name_is_absolute($val));
$self->{'settings'}->{'design'}->{$k} = $nv;
$self->update;
......@@ -1200,7 +1199,7 @@ sub _validate_fiu_entry {
my $i = shift;
my $new_ref = \shift;
my $old_ref = \@{$self->{'settings'}->{'fius'}}[$i]->{$name};
my $rv = _validate_entry(FIUMAP, $self, $widget, $name, $old_ref, $new_ref, @_);
my $rv = _validate_entry(FIUMAP, $self, $widget, $name, $old_ref, $new_ref, @_);
$self->_check_change();
return $rv;
}
......@@ -1241,9 +1240,10 @@ sub _highlight_widget ($$) {
sub _check_change {
my $self = shift;
${$self->{'change_indicator_ref'}} = eq_deeply($self->{'settings'},$self->{'original_settings'}) ?
$self->{'change_indicator_values'}->{'unchanged'} :
$self->{'change_indicator_values'}->{'changed'};
${$self->{'change_indicator_ref'}} =
eq_deeply($self->{'settings'}, $self->{'original_settings'})
? $self->{'change_indicator_values'}->{'unchanged'}
: $self->{'change_indicator_values'}->{'changed'};
}
1;
......
......@@ -169,11 +169,18 @@ sub _populate_widget ($) {
for (my $fi = 0 ; $fi < $self->{'settings'}->{'design'}->{'FIU_NUM'} ; $fi++) {
my $supported_model = @{$self->{'settings'}->{'fius'}}[$fi]->{'FIU_MODEL'};
my $ri = $fi + 5;
my $lab = $tf->Label(-text => "FIU $fi")->grid(-column => 0, -row => $ri, -sticky => "w");
my @optionlist;
my @optionlist = sort { FIUENUM->{$a} cmp FIUENUM->{$b} } keys(%{$fe_ref});
if ($supported_model eq "RUNTIME") {
@optionlist = sort { FIUENUM->{$a} cmp FIUENUM->{$b} } keys(%{$fe_ref});
} else {
@optionlist = ("NONE", $supported_model);
}
my $f1 = $tf->Optionmenu(
'-options' => \@optionlist,
......
......@@ -341,7 +341,7 @@ sub _populate_widget {
$self->{'fr_buttons'}->Label(-text => "Fault Detect:")->pack(-side => "left", -padx => 5);
$self->{'fd0'} = $self->{'fr_buttons'}->Label(-width => 2, -relief => "sunken", -borderwidth => "1", -text => "1", -bg => OKCOLOR)->pack(-side => "left");
$self->{'fd1'} = $self->{'fr_buttons'}->Label(-width => 2, -relief => "sunken", -borderwidth => "1", -text => "2", -bg => OKCOLOR)->pack(-side => "left");
$self->{'msg_type'} = $self->{'fr_buttons'}->Label(-width => 22, -text => "FIJI status", -borderwidth => "1", -relief => "sunken")->pack(-side => "left", -padx => 5);
$self->{'msg_type'} = $self->{'fr_buttons'}->Label(-width => 22, -text => "FIJI status", -borderwidth => "1", -relief => "sunken")->pack(-side => "left", -padx => 5);
$self->{'duration'} = $self->{'fr_buttons'}->Label(-width => 22, -text => "Test runtime", -borderwidth => "1", -relief => "sunken")->pack(-side => "left", -padx => 5);
#---
......@@ -517,10 +517,16 @@ sub _populate_widget {
sub update {
my $self = shift;
for my $widget (@{$self->{'widgets'}}) {
my $k = $widget->{'key'};
if (ref($widget) eq "Tk::Entry") {
$widget->configure(-text => $self->{'tests'}->{'design'}->{$widget->{'key'}});
$widget->configure(-text => $self->{'tests'}->{'design'}->{$k});
} elsif (ref($widget) eq "Tk::Checkbutton") {
$widget->configure(-variable => \$self->{'tests'}->{'design'}->{$widget->{'key'}});
$widget->configure(-variable => \$self->{'tests'}->{'design'}->{$k});
if (defined($self->{'depends'}->{$k})) {
$widget->configure('-command' => [\&_set_fields_by_button, $self, $widget, $self->{'depends'}->{$k}, []]);
}
_set_fields_by_button($self, $widget, $self->{'depends'}->{$k}, []);
}
}
......@@ -676,7 +682,7 @@ sub _validate_entry {
my $new = $$new_ref;
# dynamic validation
# type based dynamic validation
if ($stat == 1 && defined $map->{$name}->{'type'} && $map == TESTCONSTMAP) { # bleurgh
if ($map->{$name}->{'type'} eq 'min_duration') {
my $matching = $map->{$name}->{'matching'};
......@@ -706,6 +712,14 @@ sub _validate_entry {
}
}
# key based dynamic validation
if ($stat == 1 && $dyn == 1) {
if ($name eq "REPEAT_OFFSET" && ($new > @{$self->{'tests'}->{'tests'}} - 1)) {
$logger->error("$name must be smaller than number of tests");
$dyn = 0;
}
}
my $ok = $stat & $dyn;
_highlight_widget($widget, (!$ok));
......@@ -721,6 +735,41 @@ sub _validate_entry {
return 1; # always allow the new value and show the user what happened.
}
sub _set_fields_by_button {
my $logger = get_logger("");
my ($self, $button, $fields, $forbidden_by) = @_;
# check if enabling is forbidden by another enabled value
if (defined $forbidden_by && ref($forbidden_by) eq "ARRAY") {
foreach my $f (@{$forbidden_by}) {
if (ref($f) ne "Tk::Checkbutton") {
$logger->error("Type mismatch: 'forbidden_by' must only include boolean values");
} elsif (${$button->cget('-variable')} && ${$f->cget('-variable')}) {
${$button->cget('-variable')} = 0;
$self->Dialog(
-title => "Error",
-text => "\"" . $f->{'description'} . "\"\nforbids\n\"" . $button->{'description'} . "\".",
-buttons => ["OK"],
)->Show();
}
}
}
$self->_set_fields(${$button->cget('-variable')}, $fields) if (defined $fields && ref($fields) eq "ARRAY");
}
sub _set_fields {
my ($self, $bool, $fields) = @_;
my $logger = get_logger("");
foreach my $f (@{$fields}) {
if ($bool) {
$f->configure('-state' => 'normal');
} else {
$f->configure('-state' => 'disabled');
}
}
}
sub _highlight_widget ($$) {
my ($widget, $enable) = @_;
if ($enable) {
......
; Config::Simple 4.58
; Wed Sep 23 17:14:18 2015
[FIU2]
NET_NAME=i2c_master_top|cnt_RNIOCS1_combout
DRIVER_TYPE=PIN
DRIVER_PATH=i2c_master_top|byte_controller|cnt_RNIOCS1_combout_0
FAULT_MODEL=RUNTIME
LFSR_MASK=0x0
[FIU0]
DRIVER_PATH=i2c_master_bit_ctrl|al_RNIHURE|combout
DRIVER_TYPE=PIN
NET_NAME=i2c_master_top|i2c_master_byte_ctrl|i2c_master_bit_ctrl|N_152_tz
LFSR_MASK=0x0
FAULT_MODEL=RUNTIME
; Thu Sep 24 14:15:42 2015
[CONSTS]
RESET_DUT_OUT_ACTIVE=0
TRIGGER_DUT_ACTIVE=1
TRIGGER_DUT_EN=0
TRIGGER_EXT_ACTIVE=1
RESET_EXT_IN_NAME=s_fiji_reset
FIU_NUM=3
INSTRUMENTATION_LOG=fiji_instrument.log
FAULT_DETECT_2_EN=1
RESET_DUT_IN_DURATION=4
RESET_EXT_ACTIVE=0
CFGS_PER_MSG=2
LFSR_SEED=0xcafe
LFSR_POLY=0x2d
OUTPUT_DIR=.
FIU_CFG_BITS=3
TIMER_WIDTH=4
LFSR_WIDTH=32
FAULT_DETECT_1_INVERT=0
ID=0xaa4
RESET_DUT_OUT_ACTIVE=0
FAULT_DETECT_1_EN=1
TRIGGER_EXT_IN_NAME=s_fiji_trigger_ext
TRIGGER_EXT_ACTIVE=1
RESET_DUT_IN_EN=0
RESET_DUT_IN_ACTIVE=1
BAUDRATE=115200
RX_IN_NAME=s_fiji_rx_i
RESET_DUT_IN_NAME=wb_rst_i
RESET_DUT_IN_ACTIVE=1
FIU_NUM=3
ID=0xaa4
CFGS_PER_MSG=2
FAULT_DETECT_2_INVERT=1
TRIGGER_DUT_NAME=i2c_master_top|cnt_RNIOCS1_combout
FAULT_DETECT_1_NAME=i2c_master_top|i2c_master_byte_ctrl|N_11_i
TRIGGER_EXT_IN_NAME=s_fiji_trigger_ext
RESET_DUT_OUT_NAME=i2c_master_top|i2c_master_byte_ctrl|c_state_ns_0_0_0_5__g1
FAULT_DETECT_2_NAME=i2c_master_top|i2c_master_byte_ctrl|N_70
CLOCK_NET=i2c_master_top|wb_clk_i_c
TX_OUT_NAME=s_fiji_tx_o
RESET_DUT_OUT_EN=1
LFSR_POLY=0x2d
FREQUENCY=50000000
INSTRUMENTATION_LOG=fiji_instrument.log
RESET_EXT_EN=1
FAULT_DETECT_2_INVERT=1
FAULT_DETECT_1_NAME=i2c_master_top|i2c_master_byte_ctrl|N_11_i
TRIGGER_DUT_NAME=i2c_master_top|cnt_RNIOCS1_combout
TX_OUT_NAME=s_fiji_tx_o
LFSR_SEED=0xcafe
FAULT_DETECT_2_EN=1
TIMER_WIDTH=4
FAULT_DETECT_2_NAME=i2c_master_top|i2c_master_byte_ctrl|N_70
BAUDRATE=115200
RESET_DUT_IN_DURATION=4
RESET_EXT_ACTIVE=0
RESET_DUT_IN_EN=0
TRIGGER_EXT_EN=0
TRIGGER_DUT_ACTIVE=1
RESET_DUT_IN_NAME=wb_rst_i
FREQUENCY=50000000
OUTPUT_DIR=.
TRIGGER_DUT_EN=0
RESET_DUT_OUT_EN=1
FAULT_DETECT_1_INVERT=0
LFSR_WIDTH=32
[FIU1]
[FIU0]
DRIVER_PATH=i2c_master_bit_ctrl|al_RNIHURE|combout
DRIVER_TYPE=PIN
FAULT_MODEL=STUCK_AT_1
LFSR_MASK=0x0
NET_NAME=i2c_master_top|i2c_master_byte_ctrl|i2c_master_bit_ctrl|N_152_tz
[FIU1]
DRIVER_PATH=i2c_master_bit_ctrl|c_state_RNO_0_|combout
NET_NAME=i2c_master_top|i2c_master_byte_ctrl|i2c_master_bit_ctrl|c_state_ns_0_0__g0_0_0
DRIVER_TYPE=PIN
FAULT_MODEL=STUCK_OPEN
LFSR_MASK=0x0
NET_NAME=i2c_master_top|i2c_master_byte_ctrl|i2c_master_bit_ctrl|c_state_ns_0_0__g0_0_0
[FIU2]
FAULT_MODEL=RUNTIME
DRIVER_TYPE=PIN
DRIVER_PATH=i2c_master_top|byte_controller|cnt_RNIOCS1_combout_0
NET_NAME=i2c_master_top|cnt_RNIOCS1_combout
LFSR_MASK=0x0
......@@ -55,6 +55,8 @@ use constant SETTINGS_FILE_TYPES_CFG => [
['All files', '*'],
];
use constant APPNAME => 'FIJI Download Tool';
my $qw = Thread::Queue->new(); # A new empty queue
my $qr = Thread::Queue->new(); # A new empty queue
my $ql = Thread::Queue->new(); # A new empty queue
......@@ -149,7 +151,14 @@ sub main {
my $worker_tid = threads->create('download_worker');
my $mw = MainWindow->new(-title => 'FIJI Download Tool');
#
# Build GUI
#
# Assigning $0 sets a "prettier" program title in Gnome's taskbar
# Must not contain spaces (duh)
$0 = (APPNAME =~ s/\s+/\-/rg);
my $mw = MainWindow->new(-title => APPNAME);
$mw->appname(APPNAME);
$mw->withdraw();
#### Set icon
......
......@@ -50,6 +50,8 @@ use constant FILE_TYPES_NETLIST => [['Verilog Netlists', ['.v', '*.vqm']], ['All
use constant CHANGED_VALUE => "<M>";
use constant UNCHANGED_VALUE => "";
use constant APPNAME => 'FIJI Settings Editor';
my $abouttxt = <<'END_ABOUT';
#-------------------------------------------------------------------------------
# University of Applied Sciences Technikum Wien
......@@ -103,7 +105,12 @@ sub main {
#
# Build GUI
#
my $mw = MainWindow->new(-title => 'FIJI Settings Editor');
# Assigning $0 sets a "prettier" program title in Gnome's taskbar
# Must not contain spaces (duh)
$0 = (APPNAME =~ s/\s+/\-/rg);
my $mw = MainWindow->new(-title => APPNAME);
$mw->appname(APPNAME);
$self->{'mw'} = $mw;
$self->{'ctrl'} = _ctrl_frame($self, $mw);
......@@ -120,9 +127,9 @@ sub main {
$self->{'documentation_path'} = File::Spec->catpath($vol, $libdir, 'fiji.pdf');
$self->{'FIJISettingsViewer'} = $mw->FIJISettingsViewer(
-settings => $self->{'settings'},
-documentation_path => $self->{'documentation_path'},
-change_indicator_ref => \$change_indicator,
-settings => $self->{'settings'},
-documentation_path => $self->{'documentation_path'},
-change_indicator_ref => \$change_indicator,
-change_indicator_values => {'changed' => CHANGED_VALUE, 'unchanged' => UNCHANGED_VALUE}
)->pack(
'-fill' => 'both',
......@@ -280,7 +287,7 @@ sub _ctrl_frame {
# -expand => 1
);
my $cfg_lbl;
my $cfg_lbl;
my $cfg_changed_lbl;
my $cfg_btn_open;
my $cfg_btn_save;
......@@ -298,7 +305,7 @@ sub _ctrl_frame {
'-column' => 0,
'-sticky' => 'w'
);
$cfg_changed_lbl = $fr_ctrl->Label(-textvariable=>\$change_indicator,-width=>4)->grid(
$cfg_changed_lbl = $fr_ctrl->Label(-textvariable => \$change_indicator, -width => 4)->grid(
'-row' => 0,
'-column' => 1,
'-sticky' => 'w'
......@@ -588,11 +595,15 @@ sub _save_as {
sub _onexit {
my $logger = get_logger("");
my ($self, $mw) = @_;
my $response = $mw->Dialog(-title=>"Save changes?",-text=>"Settings changed.\nSave?", -buttons=>["Yes", "No"])->Show() if ($change_indicator ne UNCHANGED_VALUE);
$logger->info("Settings changed. Asking to save.") if ($change_indicator ne UNCHANGED_VALUE);
# use _save_as to give the user the chance to save under a different name
$self->_save_as if (defined $response && $response eq "Yes");
$logger->info("Save: ".(defined $response ? $response : "undef"));
if ($change_indicator ne UNCHANGED_VALUE) {
my $response = $mw->Dialog(-title => "Save changes?", -text => "Settings changed.\nSave?", -buttons => ["Yes", "No"])->Show();
$logger->info("Settings changed. Asking to save.") if ($change_indicator ne UNCHANGED_VALUE);
# use _save_as to give the user the chance to save under a different name
$self->_save_as if (defined $response && $response eq "Yes");
$logger->info("Save: " . (defined $response ? $response : "undef"));
}
exit;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment