lib/App/SeismicUnixGui/sunix/data/suswapbytes.pm untested

filter: Statementstmt 0.0% 0 / 62 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 8 totaltotal 0.0% 0 / 90 CC 5 SCAR 13.9
CC
5
Cov
0%
format
6.0
ns
6.0
swapdata
6.0
CRAP 4.0
1 package App::SeismicUnixGui::sunix::data::suswapbytes;
2  
3 =head2 SYNOPSIS
4  
5 PERL PROGRAM NAME:
6  
7 AUTHOR: Juan Lorenzo (Perl module only)
8  
9 DATE:
10  
11 DESCRIPTION:
12  
13 Version:
14  
15 =head2 USE
16  
17 =head3 NOTES
18  
19 =head4 Examples
20  
21 =head2 SYNOPSIS
22  
23 =head3 SEISMIC UNIX NOTES
24 SUSWAPBYTES - SWAP the BYTES in SU data to convert data from big endian
25  
26 to little endian byte order, and vice versa
27  
28  
29  
30 suswapbytes < stdin [optional parameter] > sdtout
31  
32  
33  
34 format=0 foreign to native
35  
36 =1 native to foreign
37  
38 swaphdr=1 swap the header byte order
39  
40 =0 do not change the header byte order
41  
42 swapdata=1 swap the data byte order
43  
44 =0 do not change the data byte order
45  
46 ns=from header if ns not set in header, must be set by hand
47  
48 Notes:
49  
50 The 'native' endian is the endian (byte order) of the machine you are
51  
52 running this program on. The 'foreign' endian is the opposite byte order.
53  
54  
55  
56 Examples of big endian machines are: IBM RS6000, SUN, NeXT
57  
58 Examples of little endian machines are: PCs, DEC
59  
60  
61  
62 Caveat: this code has not been tested on DEC
63  
64  
65  
66  
67  
68 Credits:
69  
70 CWP: adapted for SU by John Stockwell
71  
72 based on a code supplied by:
73  
74 Institute fur Geophysik, Hamburg: Jens Hartmann (June 1993)
75  
76  
77  
78 Trace header fields accessed: ns
79  
80  
81  
82 =head2 User's notes (Juan Lorenzo)
83 untested
84  
85 =cut
86  
87  
88 =head2 CHANGES and their DATES
89  
90 =cut
91  
92 use Moose;
93 our $VERSION = '0.0.1';
94  
95  
96 =head2 Import packages
97  
98 =cut
99  
100 use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants';
101  
102 use App::SeismicUnixGui::misc::SeismicUnix qw($in $out $on $go $to $suffix_ascii $off $suffix_su $suffix_bin);
103 use aliased 'App::SeismicUnixGui::configs::big_streams::Project_config';
104  
105  
106 =head2 instantiation of packages
107  
108 =cut
109  
110 my $get = L_SU_global_constants->new();
111 my $Project = Project_config->new();
112 my $DATA_SEISMIC_SU = $Project->DATA_SEISMIC_SU();
113 my $DATA_SEISMIC_BIN = $Project->DATA_SEISMIC_BIN();
114 my $DATA_SEISMIC_TXT = $Project->DATA_SEISMIC_TXT();
115  
116 my $var = $get->var();
117 my $on = $var->{_on};
118 my $off = $var->{_off};
119 my $true = $var->{_true};
120 my $false = $var->{_false};
121 my $empty_string = $var->{_empty_string};
122  
123 =head2 Encapsulated
124 hash of private variables
125  
126 =cut
127  
128 my $suswapbytes = {
129 _format => '',
130 _ns => '',
131 _swapdata => '',
132 _swaphdr => '',
133 _Step => '',
134 _note => '',
135  
136 };
137  
138 =head2 sub Step
139  
140 collects switches and assembles bash instructions
141 by adding the program name
142  
143 =cut
144  
145 sub Step {
146  
147 $suswapbytes->{_Step} = 'suswapbytes'.$suswapbytes->{_Step};
148 return ( $suswapbytes->{_Step} );
149  
150 }
151  
152  
153 =head2 sub note
154  
155 collects switches and assembles bash instructions
156 by adding the program name
157  
158 =cut
159  
160 sub note {
161  
162 $suswapbytes->{_note} = 'suswapbytes'.$suswapbytes->{_note};
163 return ( $suswapbytes->{_note} );
164  
165 }
166  
167  
168  
169 =head2 sub clear
170  
171 =cut
172  
173 sub clear {
174  
175 $suswapbytes->{_format} = '';
176 $suswapbytes->{_ns} = '';
177 $suswapbytes->{_swapdata} = '';
178 $suswapbytes->{_swaphdr} = '';
179 $suswapbytes->{_Step} = '';
180 $suswapbytes->{_note} = '';
181 }
182  
183  
184 =head2 sub format
185  
186  
187 =cut
188  
189 sub format {
190  
191 my ( $self,$format ) = @_;
192 if ( $format ne $empty_string ) {
193  
194 $suswapbytes->{_format} = $format;
195 $suswapbytes->{_note} = $suswapbytes->{_note}.' format='.$suswapbytes->{_format};
196 $suswapbytes->{_Step} = $suswapbytes->{_Step}.' format='.$suswapbytes->{_format};
197  
198 } else {
199 print("suswapbytes, format, missing format,\n");
200 }
201 }
202  
203  
204 =head2 sub ns
205  
206  
207 =cut
208  
209 sub ns {
210  
211 my ( $self,$ns ) = @_;
212 if ( $ns ne $empty_string ) {
213  
214 $suswapbytes->{_ns} = $ns;
215 $suswapbytes->{_note} = $suswapbytes->{_note}.' ns='.$suswapbytes->{_ns};
216 $suswapbytes->{_Step} = $suswapbytes->{_Step}.' ns='.$suswapbytes->{_ns};
217  
218 } else {
219 print("suswapbytes, ns, missing ns,\n");
220 }
221 }
222  
223  
224 =head2 sub swapdata
225  
226  
227 =cut
228  
229 sub swapdata {
230  
231 my ( $self,$swapdata ) = @_;
232 if ( $swapdata ne $empty_string ) {
233  
234 $suswapbytes->{_swapdata} = $swapdata;
235 $suswapbytes->{_note} = $suswapbytes->{_note}.' swapdata='.$suswapbytes->{_swapdata};
236 $suswapbytes->{_Step} = $suswapbytes->{_Step}.' swapdata='.$suswapbytes->{_swapdata};
237  
238 } else {
239 print("suswapbytes, swapdata, missing swapdata,\n");
240 }
241 }
242  
243  
244 =head2 sub swaphdr
245  
246  
247 =cut
248  
249 sub swaphdr {
250  
251 my ( $self,$swaphdr ) = @_;
252 if ( $swaphdr ne $empty_string ) {
253  
254 $suswapbytes->{_swaphdr} = $swaphdr;
255 $suswapbytes->{_note} = $suswapbytes->{_note}.' swaphdr='.$suswapbytes->{_swaphdr};
256 $suswapbytes->{_Step} = $suswapbytes->{_Step}.' swaphdr='.$suswapbytes->{_swaphdr};
257  
258 } else {
259 print("suswapbytes, swaphdr, missing swaphdr,\n");
260 }
261 }
262  
263  
264 =head2 sub get_max_index
265  
266 max index = number of input variables -1
267
268 =cut
269
270 sub get_max_index {
271 my ($self) = @_;
272 my $max_index = 3;
273  
274 return($max_index);
275 }
276
277
278 1;