sub send_order_rxi {
my($aOrder) = @_;
my($order) = $aOrder->{orders_pending_id};
eval {
### here's where I call the subroutine
### located in the rxi.pm package
my($base) = generate_rxi($Dir, $aOrder);
if ($Mail) {
queue_via_mail($base, $aOrder);
tag_order($order, 'I');
unlink($base . '.rxi');
unlink($base . '.oma');
}
};
if ($@) {
warn "rxi send $order failed: $@\n";
}
}
####
###################################################
# this is the 'if' block where the global symbol
# complaints occur
# this 'if' block is in the subroutine 'generate_rxi'
# which is part of the package rxi.pm
####################################################
if (length($aOrder->{rx_OD_Prism_Diopters}) ne 0
|| length($aOrder->{rx_OS_Prism_Diopters}) ne 0) {
my @array1 = qw($aOrder->{rx_OD_Prism_Diopters}
$aOrder->{rx_OD_Prism}
$aOrder->{rx_OD_Prism_Angle_Val}
$aOrder->{rx_OD_Prism2_Diopters} $aOrder->{rx_OD_Prism2});
my @array2 = qw($aOrder->{rx_OS_Prism_Diopters}
$aOrder->{rx_OS_Prism}
$aOrder->{rx_OS_Prism_Angle_Val}
$aOrder->{rx_OS_Prism2_Diopters}
$aOrder->{rx_OS_Prism2});
# if values are specified as Angles, convert them to direction
if ($array1[1] == 'Angle') {convertPrismData(0, \@array1);}
if ($array2[1] == 'Angle') {convertPrismData(1, \@array2);}
my $ODP1Val = $array1[0];
my $ODP1Dir = $array1[1];
my $ODP2Val = $array1[3];
my $ODP2Dir = $array1[4];
my $OSP1Val = $array2[0];
my $OSP1Dir = $array2[1];
my $OSP2Val = $array2[3];
my $OSP2Dir = $array2[4];
# Innovations only expresses prism as IN or UP
# reverse anthing that is OUT or DOWN
if ($ODP1Dir == "OUT" || $ODP1Dir == "DOWN") {
if (length($ODP1Val != 0) {$ODP1Val = '-' . $ODP1Val);}
if ($ODP1Dir == "OUT") {
$ODP1Dir = "IN");
} else {
$ODP1Dir = "UP");
}
}
### first global symbol complaint is on $ODP2Dir
if ($ODP2Dir == "OUT" || $ODP2Dir == "DOWN") {
### second global symbol complaint is on $ODP2Val
if (length($ODP2Val != 0) {$ODP2Val = '-' . $ODP2Val);}
if ($ODP2Dir == "OUT") {
$ODP2Dir = "IN");
} else {
$ODP2Dir = "UP");
}
}
### third global symbol complaint is on $OSP1Dir
if ($OSP1Dir == "OUT" || $OSP1Dir == "DOWN") {
### fourth (and final) global symbol complaint is on $OSP1Val
if (length($OSP1Val != 0) {$OSP1Val = '-' . $OSP1Val);}
if ($OSP1Dir == "OUT") {
$OSP1Dir = "IN");
} else {
$OSP1Dir = "UP");
}
}
if ($OSP2Dir == "OUT" || $OSP2Dir == "DOWN") {
if (length($OSP2Val != 0) {$OSP2Val = '-' . $OSP2Val);}
if ($OSP2Dir == "OUT") {
$OSP2Dir = "IN");
} else {
$OSP2Dir = "UP");
}
}
my $PIN_String;
my $PUP_String;
if (length($ODP1Val) > 0) {
if ($ODP1Dir == "IN") {
$PIN_String = $ODP1Val;
$PUP_String = (length($ODP2Val) > 0) ? $ODP2Val : " 0.00");
} else { #UP
$PUP_String = $ODP1Val;
$PIN_String = (length($ODP2Val) > 0) ? $ODP2Val : " 0.00");
}
} else {
$PIN_String = " 0.00";
$PUP_String = " 0.00";
}
if (length($OSP1Val) > 0) {
if ($OSP1Dir == "IN") {
$PIN_String .= (" " . $OSP1Val);
$PUP_String .= length($OSP2Val) > 0) ? (" " . $OSP2Val) : " 0.00");
} else {
$PUP_String .= (" " . $OSP1Val);
$PIN_String .= (length($OSP2Val) > 0) ? (" " . $OSP2Val) : " 0.00");
}
} else {
$PIN_String .= " 0.00";
$PUP_String .= " 0.00";
}
print FH "PIN " . $PIN_String;
print FH "PUP " . $PUP_String;
}
####
########################################################
# convert prism angle to its vertical and horizontal components
########################################################
sub convertPrismData {
my($lr) = $_[0];
my($q2q3,$q1q4);
if ($lr == 0) { # OD setup
$q2q3 = "OUT";
$q1q4 = "IN";
} else { # OS setup
$q2q3 = "IN";
$q1q4 = "OUT";
}
my $vertical_component = round($_[1]->[0] * sin($_[1]->[2] * PI/180.0) * 100.0) / 100.0;
my $horizontal_component = round($_[1]->[0] * cos($_[1]->[2] * PI/180.0) * 100.0) / 100.0;
$_[1]->[0] = abs($vertical_component);
$_[1]->[1] = (($vertical_component < 0) ? "DOWN" : "UP");
$_[1]->[3] = abs($horizontal_component);
$_[1]->[4] = (($horizontal_component < 0) ? $q2q3 : $q1q4);
return;
}
####
#############################################
# This is the beginning of the rxi.pm package
# the subroutine generate_rxi is in this
# package. I thought this may help in fixing
# the global symbol issue
#############################################
#!/usr/bin/perl -w
package Cos::rxi;
use strict;
use Getopt::Std;
use DBI;
use Cos::Constants;
use Cos::Dbh;
use Math::Trig;
BEGIN {
use Exporter ();
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
# set the version for version checking
$VERSION = 1.00;
# if using RCS/CVS, this may be preferred
$VERSION = do { my @r = (q$Revision: 1.6 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; # must be all one line, for MakeMaker
@ISA = qw(Exporter);
@EXPORT = qw(generate_rxi);
%EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
# your exported package globals go here,
# as well as any optionally exported functions
@EXPORT_OK = qw();
}
use vars @EXPORT_OK;