lib/App/SeismicUnixGui/misc/write_LSU.pm untested

filter: Statementstmt 0.0% 0 / 57 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 67 CC 2 SCAR 12.0
CC
2
Cov
0%
tool_specs
6.0
sizes
2.0
outbound
2.0
CRAP 3.3
1 package App::SeismicUnixGui::misc::write_LSU;
2  
3 use Moose;
4 our $VERSION = '0.0.1';
5  
6 my $on = 'on';
7 my $off = 'off';
8 my $nu = 'nu';
9 my ( @param, @values, @checkbutton_on_off );
10 my ( $i, $j, $k, $size, $ref_cfg );
11  
12 my $files_LSU = {
13 _note => '',
14 _outbound => '',
15 _ref_file => '',
16 _program_name => '',
17 _program_name_config => '',
18 _Step => '',
19  
20 };
21  
22 =head2 sub sunix_params
23  
24 #print("self is $self prog name is $prog_name\n");
25  
26 #foreach my $key (sort keys %$hash_ref){
27 # print("parameter $key is $hash_ref->{$key} \n\n");
28 #}
29 #print("param is $param[$k]\n");
30 #print("values is $values[$k]\n");
31 all chebutton values are turned on by default
32 checkbutton_on_off options are only for the checkbuttons to be green
33 or red
34 sunix buttons ca n be either on or off
35  
36 =cut
37  
38 #sub sunix_params {
39 # my ($self,$hash_ref) = @_;
40 # my $prog_name = $hash_ref;
41 # $ref_cfg = $read->defaults($prog_name);
42 # $size = ((scalar @$ref_cfg) )/2;
43 #
44 # for ($k=0,$i=0; $k < $size; $k++,$i=$i+2) {
45 # $param[$k] = @$ref_cfg[$i];
46 # $j = $i + 1;
47 # $values[$k] = @$ref_cfg[$j];
48 # if($values[$k] eq $nu) {
49 # $checkbutton_on_off[$k] = $off;
50 # }
51 # else {
52 # $checkbutton_on_off[$k] = $on;
53 # }
54 # }
55 # return(\@param,\@values,\@checkbutton_on_off);
56 #}
57  
58 =head2 sub
59  
60 =cut
61  
62 sub sizes {
63 $size = ( ( scalar @$ref_cfg ) ) / 2;
64 return ($size);
65 }
66  
67 =head2 sub tool_specs
68  
69 Output parameters for superflows
70 A Tool is also a superflow
71 i/p $hash_ref to iobtain entry labels and
72 values and paramters from widgets to build @CFG
73  
74 DB
75 print("prog name $program_name\n");
76 print(" save_button,save,configure,write_LSU,tool_specs $files_LSU->{_program_name_config}\n");
77 print("save,superflow,write_LSU, key/value pairs:$CFG[$i], $CFG[$j]\n");
78 #use Config::Simple;
79 #my $cfg = Config::Simple(syntax=>'ini');
80 #$cfg->write($files_LSU->{_program_name_config});
81 # print "@CFGpa\n";
82 #$cfg->ram($CFG[$i] ,$CFG[$j]);
83 #print "@CFG\n";
84  
85 =cut
86  
87 sub tool_specs {
88 my ( $self, $hash_ref ) = @_;
89  
90 use App::SeismicUnixGui::misc::name;
91 my $name = name->new();
92  
93 my $program_name = $hash_ref->{_prog_name};
94 my $length;
95 my @CFG;
96  
97 if ($program_name) {
98 $files_LSU->{_program_name} = $program_name;
99 $files_LSU->{_program_name_config} =
100 $name->change_config($program_name);
101 $length = scalar @{ $hash_ref->{_ref_values} };
102  
103 for ( my $i = 0, my $j = 0 ; $i < $length ; $i++, $j = $j + 2 ) {
104 $CFG[$j] = @{ $hash_ref->{_ref_labels} }[$i];
105 $CFG[ ( $j + 1 ) ] = @{ $hash_ref->{_ref_values} }[$i];
106 }
107  
108 # print("write_LSU,tool_specs \nprog_name:${$files_LSU->{_program_name}}\n");
109 # print("\n prog_name_config: $files_LSU->{_program_name_config}\n");
110 # print(" labels: @{$hash_ref->{_ref_labels}}\n");
111 # print(" values: @{$hash_ref->{_ref_values}}\n");
112  
113 my $file = 'junk';
114 open( OUT, ">$file" );
115  
116 printf OUT ("# ENVIRONMENT VARIABLES FOR THIS PROJECT\n");
117 printf OUT (" # Notes:\n");
118 printf OUT (" # 1. Default DATE format is DAY MONTH YEAR\n");
119 printf OUT (" # 2. only change what lies between single\n");
120 printf OUT (" # inverted commas\n");
121 printf OUT (" # 3. the directory hierarchy is\n");
122 printf OUT (" # \$PROJECT_HOME/\$date/\$line\n");
123 printf OUT (" # Warning: Do not modify \$HOME\n");
124 printf OUT (" ");
125  
126 for ( my $i = 0, my $j = 0 ; $i < $length ; $i++, $j = $j + 2 ) {
127 printf OUT (" $CFG[$j] = $CFG[($j+1)]\n");
128 }
129 close(OUT);
130  
131 return ();
132 }
133 }
134  
135 =head2 sub outbound
136  
137 =cut
138  
139 sub outbound {
140  
141 my ( $self, $outbound ) = @_;
142  
143 $files_LSU->{_outbound} = $outbound;
144  
145 }
146 1;