FIJITestFrame.pm 3.84 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#-------------------------------------------------------------------------------
#  University of Applied Sciences Technikum Wien
#
#  Department of Embedded Systems
#  http://embsys.technikum-wien.at
#
#  Josef Ressel Center for Verification of Embedded Computing Systems
#  http://vecs.technikum-wien.at
#
#-------------------------------------------------------------------------------
#  File:              FIJITestFrame.pm
#  Created on:        02.07.2015
#  $LastChangedBy$
#  $LastChangedDate$
#
#  Description:
#  FIJI Test Editor Frame
#-------------------------------------------------------------------------------


## @file

## @class Tk::FIJITestFrame
#
# 
package Tk::FIJITestFrame;

use strict;
use warnings;

use Log::Log4perl qw(get_logger);
use Scalar::Util 'blessed';
use Tk;
use Tk::widgets qw(LabFrame Label Entry Pane Button Dialog Checkbutton CompleteEntry NoteBook);

use Tk::DynaMouseWheelBind;


use base qw(Tk::Frame);

use FIJI qw(:all);
use FIJI::Tests;

use Data::Dumper;

Construct Tk::Widget 'FIJITestFrame';

sub ClassInit {
  my($class, $mw) = @_;
  $class->SUPER::ClassInit($mw);
  
  my $self = bless {}, $class;
  return $self;
}


sub Populate {
  my $logger = get_logger();
  my($self, $args) = @_;
  $self->{'test'} = delete $args->{'-test'};
  my $settings = delete $args->{'-settings'};

  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...");
  } else {
    $self->{'settings'} = $settings;
  }
  $self->ConfigSpecs(
        -test     => [qw/METHOD test       Test/,      undef],
  );
  # FIXME: add an option to store a CODE reference that is called when any field is invalid
  $self->SUPER::Populate($args);
  $self->update();
}

sub test {
    my ($self, $test) = @_;
    $self->{'test'} = $test;
    $self->update;
}

sub _populate_widget ($) {
    my ($self, $p) = @_;

    my $tf = $p->Frame();

    $tf->Label(-text=>"Duration t1")->grid(-column=> 0,-row=> 0);
    $tf->Label(-text=>"Duration t2")->grid(-column=> 0,-row=> 1);
    $tf->Label(-text=>"Trigger")->grid(-column=> 0,-row=> 2);
    $tf->Label(-text=>"Reset DUT after config")->grid(-column=> 0,-row=> 3);

    my @to = qw(INT EXT NONE);

    $tf->Entry(-textvariable=>$self->{'test'}->{'TIMER_VALUE_1'})->grid(-column=> 1,-row=> 0);
    $tf->Entry(-textvariable=>$self->{'test'}->{'TIMER_VALUE_2'})->grid(-column=> 1,-row=> 1);
    $tf->Optionmenu(
        '-options' => \@to,
        '-width' => 15,
        '-variable' => \$self->{'test'}->{"TRIGGER"}
    )->grid(-column=>1,-row=>2);
    my $cb = $tf->Checkbutton(-variable=>$self->{'test'}->{'RESET_DUT_AFTER_CONFIG'})->grid(-column=>1,-row=>3);

    $cb->select() if ($self->{'test'}->{'RESET_DUT_AFTER_CONFIG'});

    my $ff = $p->Frame();

    $ff->Label(-text=>"FIU #")->grid(-column=> 0,-row=> 0);
    $ff->Label(-text=>"Pattern 1")->grid(-column=>1,-row=>0);
    $ff->Label(-text=>"Pattern 2")->grid(-column=>2,-row=>0);

    for (my $fi = 0; $fi < $self->{'settings'}->{'design'}->{'FIU_NUM'}; $fi++) {

        my $ri = $fi + 1;

        $ff->Label(-text=>"FIU $fi")->grid(-column=>0,-row=>($fi+1));
        #my $var1;    
        #my $var2;    
        my @optionlist = sort {FIUENUM->{$a} cmp FIUENUM->{$b}} keys(FIUENUM);

        $ff->Optionmenu(
          '-options' => \@optionlist,
          '-width' => 15,
          '-variable' => \$self->{'test'}->{"FIU_${fi}_PATTERN_1"}
         )->grid(-column=>1,-row=>($ri));

        $ff->Optionmenu(
          '-options' => \@optionlist,
          '-width' => 15,
          '-variable' => \$self->{'test'}->{"FIU_${fi}_PATTERN_2"}
         )->grid(-column=>2,-row=>($ri));
    }
    $tf->pack();
    $ff->pack();
}

sub update {
  my ($self) = @_;
  for my $child ($self->children) {
    $child->destroy;
  }
  $self->_populate_widget($self);

}