Orac-alpha

 view release on metacpan or  search on metacpan

orac_Monitor.pm  view on Meta::CPAN


sub run_the_startup {

   my $self = shift;

   my ($countdown_ref,
       $mon_text_ref,
       $stop_ref,
       $win_ref,
       $prog_bar_ref,
       $delay_ref,
       $browse_but_ref,
       $exit_but_ref,
       $start_but_ref,
       $stop_but_ref,

      ) = @_;

   # Get the original top right text.

   my $top_right_txt = $$mon_text_ref;

   # Check the delay is acceptable

   if ($$delay_ref < 15)
   {
      main::mes($self->{mon_win},
                "Time Delay must be at least 15 seconds",
               );
      return;
   }

   # Size up the Progress Bar and shutdown the Browse Button,
   # and the Exit button.  Also flick round the
   # start and stop buttons.

   $$browse_but_ref->configure(-state => 'disabled');
   $$exit_but_ref->configure(-state => 'disabled');
   $$start_but_ref->configure(-state => 'disabled');
   $$stop_but_ref->configure(-state => 'normal');

   $$prog_bar_ref->configure(
      -to => $$delay_ref,
                            );
   $$prog_bar_ref->update;

   # Now, into the main while loop

   $$countdown_ref = $$delay_ref;

   $$mon_text_ref = 'Preparing for Launch...';

   $$stop_ref = 1;

   # Run some checking Baby!

   $self->{mon_win}->Busy(-recurse=>1);

   $self->check_the_monitor;

   $self->{mon_win}->Unbusy;

   while($$stop_ref)
   {
      select(undef, undef, undef, $countdown_amount);
      $$countdown_ref = $$countdown_ref - $countdown_amount;

      my $countdown_bit = sprintf("%5.2f", $$countdown_ref);
      $$mon_text_ref = 'T-minus ' . $countdown_bit . ' (secs)';


      if ( Tk::Exists($$prog_bar_ref) )
      {
         $$prog_bar_ref->update;
      }
      else
      {
         last;
      }

      if (($$stop_ref) && ($$countdown_ref <= 0.05)) # $countdown_amount/2 ?
      {
         $$mon_text_ref = 'Initialising...';

         # Lock out the screen, then Launch, Launch, Launch!!!

         $self->{mon_win}->Busy;
         $self->check_the_monitor;
         $self->{mon_win}->Unbusy;

         if ( Tk::Exists($$prog_bar_ref) )
         {
            $$prog_bar_ref->update();
         }
         else
         {
            last;
         }

         # Reset the countdown

         $$countdown_ref = $$delay_ref;

      }
   }

   $$mon_text_ref = $top_right_txt;
   $$countdown_ref = 0;

   # Heck, these keys are taking over the asylum! :-)

   foreach my $key_db ( keys(%{$self->{nm}} ))
   {
      foreach my $key ( keys(%{$self->{nm}->{$key_db}->{labf}->{flag}} ))
      {
         if ( Tk::Exists( $self->{nm}->{$key_db}->{labf}->{flag}->{$key} ) )
         {
            $self->{nm}->{$key_db}->{labf}->{flag}->{$key}->configure(

                                          -image=> $self->{ball}->{white},

                                                                     );
         }
      }
   }

   # Enable the Browse Button

   if ( Tk::Exists($$browse_but_ref) )
   {
      $$browse_but_ref->configure(-state => 'normal');
   }

   # Enable the Exit Button


   if ( Tk::Exists($$exit_but_ref) )
   {
      $$exit_but_ref->configure(-state => 'normal');
   }

   # Flick round the start and stop buttons.

   if ( Tk::Exists($$stop_but_ref) )
   {
      $$stop_but_ref->configure(-state => 'disabled');
   }

   if ( Tk::Exists($$start_but_ref) )



( run in 1.092 second using v1.01-cache-2.11-cpan-97f6503c9c8 )