#!/usr/bin/perl #---------------------------------------------------------------------------------------------# # This script allows a more fine-grained ARCNET download of the MVD components. Functionality # is copied from the standard feed.pl, found on phoncsb at # /export/software/oncs/proLinux/install/Linux.i686.2.95-7.3/bin/feed.pl # April 2003 Hubert van Hecke #---------------------------------------------------------------------------------------------# use Tk; $x0 = 60; # start of 'T1' button $y0 = 30; # start of 'T1' button $dy = 28; # vertical button spacing $x1 = $x0+32; # start of S strips $x2 = $x0+170; # start of N strips $x3 = $x0+300; # start of nw pd $y1 = $y0+120; # start of east $xwidth = $x3+80; $yheight = 280; $ONLINE_CONFIGURATION = $ENV{ONLINE_CONFIGURATION}; $ARCNET_DATA = "$ONLINE_CONFIGURATION/Arcnet"; $ARCNET_CLIENT = "arcnet_client"; $GLINKRESET = "glinkreset"; $GTMCOMMAND = "gtmcommand"; my $mainwindow = MainWindow->new; $mainwindow->title(" MVD detailed feed"); #--------------------- Top frame: ----------------------------------------------------------------- $frametop = $mainwindow->Frame(-background=>'#dddddd') ->pack(-side=>'top', -expand=>'1', -fill=>'x'); $frametop->Label()->pack(-side=>'left', -anchor=>w, -expand=>'1', -fill=>'x', -fill=>'y'); $frametop->Label()->pack(-side=>'right', -anchor=>e, -expand=>'1', -fill=>'x', -fill=>'y'); $gtm=1; $dcim=1; $tcim=1; $fpga=1; $serial=1; $read=1; $cb0 = $frametop->Checkbutton(-text=>'GTM reset (global)', -variable=>\$gtm)->pack(-anchor=>w); $cb1 = $frametop->Checkbutton(-text=>'DCIM download (global)', -variable=>\$dcim)->pack(-anchor=>w); $cb2 = $frametop->Checkbutton(-text=>'TCIM download (global)', -variable=>\$tcim)->pack(-anchor=>w); $cb3 = $frametop->Checkbutton(-text=>'MCM fpga download', -variable=>\$fpga)->pack(-anchor=>w); $cb4 = $frametop->Checkbutton(-text=>'MCM serial download', -variable=>\$serial)->pack(-anchor=>w); $cb5 = $frametop->Checkbutton(-text=>'MCM serial read', -variable=>\$read)->pack(-anchor=>w); #--------------------- MVD frame: ----------------------------------------------------------------- $framemvd = $mainwindow->Frame(-background=>'white', -width=>$xwidth+12, -height=>$yheight+12) ->pack(-side=>'top', -expand=>'1', -fill=>'x'); #------------- WEST: ---------------- # syntax: -command=>[\&lv_sendread, 0, 0]) $framemvd->Button(-text=>"sw ob", -bd=>1, -width=>15, -background=>"#cc9966", -command=>[\&one_feed,"sw-ob"]) ->place(-x=>$x1, -y=>$y0); $framemvd->Button(-text=>"sw ib", -bd=>1, -width=>15, -background=>"#cc9966", -command=>[\&one_feed,"sw-ib"]) ->place(-x=>$x1, -y=>$y0+1*$dy); $framemvd->Button(-text=>"sw im", -bd=>1, -width=>15, -background=>"#cc9966", -command=>[\&one_feed,"sw-im"]) ->place(-x=>$x1, -y=>$y0+2*$dy); $framemvd->Button(-text=>"sw it", -bd=>1, -width=>15, -background=>"#cc9966", -command=>[\&one_feed,"sw-it"]) ->place(-x=>$x1, -y=>$y0+3*$dy); $framemvd->Button(-text=>"nw ob", -bd=>1, -width=>15, -background=>"#cc9966", -command=>[\&one_feed,"nw-ob"]) ->place(-x=>$x2, -y=>$y0); $framemvd->Button(-text=>"nw ib", -bd=>1, -width=>15, -background=>"#cc9966", -command=>[\&one_feed,"nw-ib"]) ->place(-x=>$x2, -y=>$y0+1*$dy); $framemvd->Button(-text=>"nw im", -bd=>1, -width=>15, -background=>"#cc9966", -command=>[\&one_feed,"nw-im"]) ->place(-x=>$x2, -y=>$y0+2*$dy); $framemvd->Button(-text=>"nw it", -bd=>1, -width=>15, -background=>"#cc9966", -command=>[\&one_feed,"nw-it"]) ->place(-x=>$x2, -y=>$y0+3*$dy); $framemvd->Button(-text=>"sw\npd", -bd=>1, -width=>1, height=>7, -background=>"#cc9966", -command=>[\&one_feed,"sw-pd"]) ->place(-x=>$x0, -y=>$y0); $framemvd->Button(-text=>"nw\npd", -bd=>1, -width=>1, height=>7, -background=>"#cc9966", -command=>[\&one_feed,"nw-pd"]) ->place(-x=>$x3, -y=>$y0); #----------------- EAST: $framemvd->Button(-text=>"se it", -bd=>1, -width=>15, -background=>"#cc9966", -command=>[\&one_feed,"se-it"]) ->place(-x=>$x1, -y=>$y1); $framemvd->Button(-text=>"se im", -bd=>1, -width=>15, -background=>"#cc9966", -command=>[\&one_feed,"se-im"]) ->place(-x=>$x1, -y=>$y1+1*$dy); $framemvd->Button(-text=>"se ib", -bd=>1, -width=>15, -background=>"#cc9966", -command=>[\&one_feed,"se-ib"]) ->place(-x=>$x1, -y=>$y1+2*$dy); $framemvd->Button(-text=>"se ob", -bd=>1, -width=>15, -background=>"#cc9966", -command=>[\&one_feed,"se-ob"]) ->place(-x=>$x1, -y=>$y1+3*$dy); $framemvd->Button(-text=>"ne it", -bd=>1, -width=>15, -background=>"#cc9966", -command=>[\&one_feed,"ne-it"]) ->place(-x=>$x2, -y=>$y1); $framemvd->Button(-text=>"ne im", -bd=>1, -width=>15, -background=>"#cc9966", -command=>[\&one_feed,"ne-im"]) ->place(-x=>$x2, -y=>$y1+1*$dy); $framemvd->Button(-text=>"ne ib", -bd=>1, -width=>15, -background=>"#cc9966", -command=>[\&one_feed,"ne-ib"]) ->place(-x=>$x2, -y=>$y1+2*$dy); $framemvd->Button(-text=>"ne ob", -bd=>1, -width=>15, -background=>"#cc9966", -command=>[\&one_feed,"ne-ob"]) ->place(-x=>$x2, -y=>$y1+3*$dy); $framemvd->Button(-text=>"se\npd", -bd=>1, -width=>1, height=>7, -background=>"#cc9966", -command=>[\&one_feed,"se-pd"]) ->place(-x=>$x0, -y=>$y1); $framemvd->Button(-text=>"ne\npd", -bd=>1, -width=>1, height=>7, -background=>"#cc9966", -command=>[\&one_feed,"ne-pd"]) ->place(-x=>$x3, -y=>$y1); #----- LABELS: $framemvd->Label(-text=>"SOUTH", -bd=>1, -width=>6, -background=>"#ffffff") ->place(-x=>$x0-50, -y=>$y1-13); $framemvd->Label(-text=>"NORTH", -bd=>1, -width=>6, -background=>"#ffffff") ->place(-x=>$x3+33, -y=>$y1-13); $framemvd->Label(-text=>"WEST", -bd=>1, -width=>6, -background=>"#ffffff") ->place(-x=>$x2-30, -y=>$y0-20); $framemvd->Label(-text=>"EAST", -bd=>1, -width=>6, -background=>"#ffffff") ->place(-x=>$x2-30, -y=>$y1+115); #----------- BOTTOM FRAME: ------------------------------------------ $framebot = $mainwindow->Frame(-background=>'#ffcc66') ->pack(-side=>'left', -expand=>'1', -fill=>'x'); $framebot->Button(-text=>"exit", -command=>sub{exit} )->pack(-side=>'left', -anchor=>'sw'); $framebot->Button(-text=>"all full feed", -command=>[\&all_feed,"MVD.ALL"] )->pack(-side=>'right', -anchor=>'sw'); $framebot->Button(-text=>"all fast feed", -command=>[\&all_feed,"MVD"] )->pack(-side=>'right', -anchor=>'sw'); MainLoop; #===========================================================================# sub all_feed { # lifted from feed.pl on phoncsb 7 april 03 $MAXIMUM_POSSIBLE_STEPS = 150; $sys = $_[0]; # = first passed argument print("Subroutine all_feed - argument seen: $sys \n"); %command = ('MVD'=>[["$GLINKRESET GTM.MVD", 1, "glinkreset", 0], ["$ARCNET_CLIENT $ARCNET_DATA/mvd/acf/mvd_tcim_check_glink.acf", 1, "check glink", 0], ["$ARCNET_CLIENT $ARCNET_DATA/mvd/acf/mvd_mcm_serial_run.acf", 1, "init MCM", 0], ["$ARCNET_CLIENT $ARCNET_DATA/mvd/acf/mvd_mcm_read_serial.acf", 1, "check MCM serial", 0] ], 'MVD.ALL'=>[["$GLINKRESET GTM.MVD", 1, "glinkreset", 0], ["$ARCNET_CLIENT $ARCNET_DATA/mvd/acf/mvd_dcim_fpga.acf", 0, "init DCIM", 0], ["$ARCNET_CLIENT $ARCNET_DATA/mvd/acf/mvd_tcim_check_glink.acf", 1, "check glink", 0], ["$ARCNET_CLIENT $ARCNET_DATA/mvd/acf/mvd_mcm_fpga.acf", 0, "init MCM", 0], ["$ARCNET_CLIENT $ARCNET_DATA/mvd/acf/mvd_mcm_serial_run.acf", 1, "online", 0], ["$ARCNET_CLIENT $ARCNET_DATA/mvd/acf/mvd_mcm_read_serial.acf", 1, "check MCM serial", 0] ]); COMMANDS: for $i ( 0 .. $MAXIMUM_POSSIBLE_STEPS ) { if ( defined( $command{$sys}[$i][0] ) ) { #print "command: $command{$sys}[$i][0] \n"; #print "checkit?: $command{$sys}[$i][1] \n"; #print "error: $command{$sys}[$i][2] \n"; $repeat_count = 1; if ( defined( $command{$sys}[$i][4] ) ) { $repeat_count = $command{$sys}[$i][4]; # print "repeat: $command{$sys}[$i][4] \n"; } #$message{$sys_button} = "Working...\n $command{$sys}[$i][2]"; #$button_frame->update(); for ( 1 .. $repeat_count ) { # this is the only command that accesses any hardware # replace this with $rc = 0; print "executing: $command{$sys}[$i][0] \n"; # and you can test the gui without actually doing anything $rc = system( $command{$sys}[$i][0] ); if ( $rc !=0 && $command{$sys}[$i][1] != 0 ) { #print = ("ERROR\n$command{$sys}[$i][2]"); $errors++; last COMMANDS; } # delay for the number of seconds in the command hash sleep( $command{$sys}[$i][3] ); } # end for repeat_count } # end if defined } # end for MAX_STEPS } # end of sub all_feed #==============================================================# sub one_feed { $grp = $_[0]; # = first passed argument print("Subroutine one_feed - argument seen: $grp \n"); if ($gtm){ #------------------- GTM RESET ------------------- $rc = 0; print ("executing: $GLINKRESET GTM.MVD \n"); $rc = system( "$GLINKRESET GTM.MVD" ); if ( $rc !=0 && $command{$sys}[$i][1] != 0 ) { print ("GTM reset problem \n"); $errors++; } } if ($dcim){ #------------------ DCIM DOWNLOAD ------------------ $rc = 0; print ("executing: $ARCNET_CLIENT $ARCNET_DATA/mvd/acf/mvd_dcim_fpga.acf \n"); $rc = system( "$ARCNET_CLIENT acf/mvd_dcim_fpga.acf" ); if ( $rc !=0 && $command{$sys}[$i][1] != 0 ) { print ("DCIM download problem \n"); $errors++; } } if ($tcim){ #---------------- TCIM DOWNLOAD ------------------- $rc = 0; print ("executing: $ARCNET_CLIENT $ARCNET_DATA/mvd/acf/mvd_tcim_check_glink.acf \n"); $rc = system( "$ARCNET_CLIENT acf/mvd_tcim_check_glink.acf" ); if ( $rc !=0 && $command{$sys}[$i][1] != 0 ) { print ("TCIM glink problem \n"); $errors++; } } if ($fpga){ #------------------- MCM FPGA DOWNLOAD --------------- $rc = 0; $command = $ARCNET_CLIENT." /home/phnxrc/mvd/vme/acf/".$grp."_mcm_fpga.acf"; print ("executing: $command \n"); $rc = system( "$command" ); if ( $rc !=0) { print ("MCM xilinx download problem \n"); $errors++; } } if ($serial){ #------------------- SERIAL DOWNLOAD ----------------- $rc = 0; $command = $ARCNET_CLIENT." /home/phnxrc/mvd/vme/acf/".$grp."_mcm_serial_run.acf"; print ("executing: $command \n"); $rc = system( "$command" ); if ( $rc !=0) { print ("MCM serial string download problem \n"); $errors++; } } if ($read){ #------------------- SERIAL READBACK ----------------- $rc = 0; $command = $ARCNET_CLIENT." /home/phnxrc/mvd/vme/acf/".$grp."_mcm_read_serial.acf"; print ("executing: $command \n"); $rc = system( "$command" ); if ( $rc !=0) { print ("MCM serial readback problem \n"); $errors++; } } } # end of sub one_feed #==================================================