]> jspc29.x-matter.uni-frankfurt.de Git - mimosis_chain.git/commitdiff
worked on cli
authorMaps <maps@ikf>
Thu, 12 Dec 2024 10:30:38 +0000 (11:30 +0100)
committerMaps <maps@ikf>
Thu, 12 Dec 2024 10:30:38 +0000 (11:30 +0100)
scripts/cli/mimosis

index 9931d633e224534f8ca78cb93dad553cbef75adc..5d846386421e9e3bc210289395dca1d597cee054 100755 (executable)
 
 use Getopt::Long::Subcommand;
 use HADES::TrbNet;
-use lib '/d/jspc37/mimosis/scripts/';
+# use ExtUtils::testlib;
+# use lib '/d/jspc37/mimosis/scripts/modules/Mimosis/blib/lib';
+# use lib '/d/jspc37/mimosis/scripts';
 use Mimosis;
 use Time::HiRes qw(usleep sleep);
 use Data::Dump qw(dump);
 use File::Copy;
 
 
-$SIG{INT} = sub {
-    Mimosis::kill_proc_by_pid_file("/tmp/hldprint-pid");
-    die "\nAbort.\n"
-};
-
-
-
-my %dacs = (
-    IBIAS => 0x0040,
-    ITHR  => 0x0041,
-    IDB   => 0x0042,
-    VRESET => 0x0043,
-    VPL    => 0x0044,
-    VPH    => 0x0045,
-    VPH_FINE => 0x0046,
-    VCASP    => 0x0047,
-    VCASNA   => 0x0048,
-    VCASNB   => 0x0049,
-    VCASNC   => 0x004a,
-    VCASND   => 0x004b,
-    VCASN2   => 0x004c,
-    VCLIP    => 0x004d,
-    IBUFBIAS => 0x004e
-    );
+
+
+sub dos_valid {
+    my $dos = $_[0];
+
+    return
+        $dos eq 'jspc29:109' ||
+       $dos eq 'jspc29:150' ||
+       $dos eq 'jspc29:7';
+}
+
+my $dos = $ENV{'DAQOPSERVER'};
+
+if ( !dos_valid($dos) ) {
+
+    print "\nDAQOPSERVER not defined or wrong value!!\n";
+
+    do {
+        print("Which setup?\n");
+        print("1  Lab317\n");
+        print("2  Probestation\n");
+        print("3  Lab318\n");
+        print("Choose [1,2,3]: ");
+
+        my $choice = <STDIN>;
+        chomp $choice;
+
+        if( $choice ne '2' and
+            $choice ne '1' and
+           $choice ne '3' ) {
+            print("Not a valid input.\n");
+        } elsif( $choice eq '1' ) {
+            $dos = 'jspc29:150';
+        } elsif( $choice eq '2' ) {
+            $dos = 'jspc29:109';
+        } elsif( $choice eq '3' ) {
+            $dos = 'jspc29:7';
+        }
+    } while !dos_valid($dos);
+
+    $ENV{'DAQOPSERVER'} = $dos;
+
+    do "mimosis " . join( " ", @ARGV );
+}
+
+
+
+
+sub help_global {
+    my $message = <<'END_MESSAGE';
+                                =+-                  =*=
+                                +*==:              :##=-
+           -::::-:.    .-:::=:. =+@*.              .+@+-   .-::::::::--:.
+          .=    .*-.  .=.   :#=. .*%- .:-----------=%%=----*+.         .:--.
+         .:-     .*-..=:     =*:..:%%==-::::::::::-#%-::==*-    -----:     ==..
+     .....=.      :*--:       ++-==+#+::::::::::::+#*==-.:-    +#+--==++.   :*:..
+   .......+    -   :#=   .- .-=+-:::--:::::::::::=*#-....=    :%+:.....:=:   -*:..
+   ......:-   .%+   .   .#%+=--=*====##==========#%=....=-    *#-.......:+    #=...
+  .......=.   =#+=     :#*=+    *+:..*@#========*@#======+*+-+#=:........=    +*:..
+  .......=    **--=   :#*-.--   :#+==-#%=::::::-%%-::-=+-.  .#*:.........+    **:..
+   .....:=   :%+:.-= :#*-...+::-==-:::-=-::::::-=--==-=-    *#-.........--   :%+..
+     ...-:   =#-...-+#*-..:=*#+===+=====++=====++=-...=    =%+:........--    *#-.
+       .=    #*:....:-:......:+   :#-..:#%:..:%%:....=.   :#*=--------:.   .##=.
+       .=   :%=.     .       .-:   ++:. -%*..+@=    :-                   :+#+-.
+       :+:::+#-.              .=:::-#-.  +@--%*.   .+-::::::::::::::--=*#*=:.
+        :++++=.                .-++++-.  .%%%%:     :=+++++++++++++++==-:.
+                                          =@@+
+                                           ##.
+
+usage: mimosis [GLOBAL OPTIONS] <command> [COMMAND OPTIONS]
+
+GLOBAL OPTIONS are:
+    -f, --fpga=FPGA      ->  Hex address of the FPGA. Defaults to 0xa000.
+    -s, --sleepval1=VAL  ->  Execute I2C commands with a pause of NUM microseconds in between.
+    -a, --singleaccess   ->  Select single access mode.
+    -c, --chipid=CHIPID  ->  Use ChIPID to address sensor.
+    -u, --uart           ->  Use UART backend in TRBNet.
+    -i, --ikf            ->  Use settings for IKF proxy.
+    -m, --mbs            ->  Set stream link for Go4analysis, like mbss://localhost:36789
+    -d, --i2cspeed=VAL   ->  Use VAL as I2C speed (default: 30).
+    -p, --printall       ->  Print all informations possible.
+    -h, --help           ->  Print this or <command> specific help.
+
+<commands> are:
+    reg         Write/Read a register.
+    instr       Send an instruction.
+    dacscan     Make a DAC scan.
+    scurves     Make a S-Curve scan.
+    mask        Mask pixels.
+    pulse       Pulse pixles.
+    load        Write registers from configuration file.
+    adc
+    vnc         Open a vncviewer with preconfigured setup.
+
+For every <command> a short description is accessible with the -h and --help options.
+END_MESSAGE
+    print $message;
+    exit 0;
+}
+
+
+
+
+sub help_load {
+    my $message = <<'END_MESSAGE';
+
+usage: mimosis [GLOBAL OPTIONS] load [COMMAND OPTIONS] PATH
+
+GLOBAL OPTIONS are:
+    -f, --fpga=FPGA      ->  Hex address of the FPGA. Defaults to 0xa000.
+    -s, --sleepval1=VAL  ->  Execute I2C commands with a pause of NUM microseconds in between.
+    -a, --singleaccess   ->  Select single access mode.
+    -c, --chipid=CHIPID  ->  Use ChIPID to address sensor.
+    -u, --uart           ->  Use UART backend in TRBNet.
+    -i, --ikf            ->  Use settings for IKF proxy.
+    -m, --mbs            ->  Set stream link for Go4analysis, like mbss://localhost:36789
+    -d, --i2cspeed=VAL   ->  Use VAL as I2C speed (default: 30).
+    -p, --printall       ->  Print all informations possible.
+    -h, --help           ->  Print this or <command> specific help.
+
+COMMAND OPTIONS are:
+    -w, --printwrong    ->  Print all settings, that were not loaded to mimosis correctly stdout.
+
+EXAMPLES:
+# Load configuration given by the file in conf/CONF_allregister.pl.
+# Print all values, that were not loaded correctly.
+mimosis load --printwrong conf/CONF_allregisters.pl
+
+END_MESSAGE
+
+    print $message;
+    exit 0;
+}
+
+
+
+sub help_dacscan {
+    my $message = <<'END_MESSAGE';
+
+usage: mimosis [GLOBAL OPTIONS] dacscan [DACS]
+
+GLOBAL OPTIONS are:
+    -f, --fpga=FPGA      ->  Hex address of the FPGA. Defaults to 0xa000.
+    -s, --sleepval1=VAL  ->  Execute I2C commands with a pause of NUM microseconds in between.
+    -a, --singleaccess   ->  Select single access mode.
+    -c, --chipid=CHIPID  ->  Use ChIPID to address sensor.
+    -u, --uart           ->  Use UART backend in TRBNet.
+    -i, --ikf            ->  Use settings for IKF proxy.
+    -m, --mbs            ->  Set stream link for Go4analysis, like mbss://localhost:36789
+    -d, --i2cspeed=VAL   ->  Use VAL as I2C speed (default: 30).
+    -p, --printall       ->  Print all informations possible.
+    -h, --help           ->  Print this or <command> specific help.
+
+
+Scan all dacs or only those, specified by the whitespaces delimited list DACS.
+
+EXAMPLE:
+
+# Uses all default values and scans all DACs.
+mimosis dacscan
+
+# Uses settings for IKFv2 Proxy and scans only IBIAS and VPHFINE.
+mimosis --ikf dacscan IBIAS VPHFINE
+
+END_MESSAGE
+
+    print $message;
+    exit 0;
+}
+
+
+
+sub help_scurves {
+    my $message = <<'END_MESSAGE';
+
+usage: mimosis [GLOBAL OPTIONS] scurves [COMMAND OPTIONS]
+
+The data will be priveded in a folder in the current directory with the time started as name.
+The data is sorted by the VCASN, if --vcasn is not provided, or by
+
+GLOBAL OPTIONS are:
+    -f, --fpga=FPGA      ->  Hex address of the FPGA. Defaults to 0xa000.
+    -s, --sleepval1=VAL  ->  Execute I2C commands with a pause of NUM microseconds in between.
+    -a, --singleaccess   ->  Select single access mode.
+    -c, --chipid=CHIPID  ->  Use ChIPID to address sensor.
+    -u, --uart           ->  Use UART backend in TRBNet.
+    -i, --ikf            ->  Use settings for IKF proxy.
+    -m, --mbs            ->  Set stream link for Go4analysis, like mbss://localhost:36789
+    -d, --i2cspeed=VAL   ->  Use VAL as I2C speed (default: 30).
+    -p, --printall       ->  Print all informations possible.
+    -h, --help           ->  Print this or <command> specific help.
+
+COMMAND OPTIONS are:
+        --ystart=YSTART          ->  Start scan in y-direction from YSTART. Default 0.
+        --ystop=YSTOP            ->  Scan in y-direction until YSTOP. Default 503.
+        --ystep=YSTEP            ->  Scan in y-direction every YSTEP. Default 1.
+        --yspan=YSPAN            ->  Scan YSPAN rows at once.
+        --xstart=XSTART          ->  Start scan in x-direction form XSTART. Default 0.
+        --xstop=XSTOP            ->  Scan in x-direction until XSTOP. Default 1023.
+        --xstep=XSTEP            ->  Scan in x-direction every XSTEP. Default 1.
+        --setstart=SETSTART      ->  Start VPHFINE-scan at SETSTART. Default 0.
+        --setstop=SETSTOP        ->  Scan VPHFINE until SETSTOP. Default 255.
+        --setstep=SETSTEP        ->  Scan VPHFINE every SETSTEP. Default 1.
+        --setcount=SETCOUNT      ->  Collect data for each VPHFINE setting for SETCOUNT frames. Default 4000.
+        --vcasnreg=VCASNREG      ->  Make scurve scans for VCASNREG. Valid values are 'VCASNA', 'VCASNB', 'VCASNC', 'VCASND', 'VCASN2'
+        --vcasnstart=VCASNSTART  ->  Start at VCASNSTART. Default 0.
+        --vcasnstop=VCASNSTOP    ->  Stop at VCASNSTOP. Default 255.
+        --vcasnstep=VCASNSTEP    ->  Make scurve every VCASNSTEP. Default 1.
+        --modexp=MODEXP          ->  Pulse every 2**MODEXP frames. Default 3.
+        --modfound=MODFOUND      ->  If modulus of the mimosis frame counter, where pulsing is done, is known, set MODFOUND to it. Other wise a search will be done anyway.
+        --pixpulseAA=PIXPULSEAA  ->  MSB and LSB of PIXPULSEA_A register. Default 25.
+        --pixpulseAB=PIXPULSEAB  ->  MSB and LSB of PIXPULSEA_B register. Default 75.
+        --pixpulseDA=PIXPULSEDA  ->  MSB and LSB of PIXPULSED_A register. Default 0.
+        --pixpulseDB=PIXPULSEDB  ->  MSB and LSB of PIXPULSED_B register. Default 0.
+
+EXAMPLES:
+# Scan Matrix B from 80 to 130 every 5 settings.
+mimosis scurves --yspan 2 --xstart 128 --xstop 511 --vcasnreg 0x49 --vcasnstart 80 --vcasnstop 130 --vcasnstep 5
+
+END_MESSAGE
+
+    print $message;
+    exit 0;
+}
+
+
+
+
+
+sub help_mask {
+    my $message = <<'END_MESSAGE';
+
+usage: mimosis [GLOBAL OPTIONS] mask [COMMAND OPTIONS]
+
+GLOBAL OPTIONS are:
+    -f, --fpga=FPGA      ->  Hex address of the FPGA. Defaults to 0xa000.
+    -s, --sleepval1=VAL  ->  Execute I2C commands with a pause of NUM microseconds in between.
+    -a, --singleaccess   ->  Select single access mode.
+    -c, --chipid=CHIPID  ->  Use ChIPID to address sensor.
+    -u, --uart           ->  Use UART backend in TRBNet.
+    -i, --ikf            ->  Use settings for IKF proxy.
+    -m, --mbs            ->  Set stream link for Go4analysis, like mbss://localhost:36789
+    -d, --i2cspeed=VAL   ->  Use VAL as I2C speed (default: 30).
+    -p, --printall       ->  Print all informations possible.
+    -h, --help           ->  Print this or <command> specific help.
+
+COMMAND OPTIONS are:
+        --xstart XSTART     ->  Start masking in x-diraction from XSTART. Default 0.
+        --xstop XSTOP       ->  Mask in x-direction until XSTOP. Default 1023.
+        --xstep XSTEP       ->  Mask every XSTEP pixel in x-direction. Default 1.
+        --ystart YSTART     ->  Start masking in y-diraction from YSTART. Default 0.
+        --ystop YSTOP       ->  Mask in y-direction until YSTOP. Default 503.
+        --ystep YSTEP       ->  Mask every YSTEP pixel in y-direction. Default 1.
+
+EXAMPLES:
+# Mask the first 100x100 pixels.
+mimosis mask --xstop 100 --ystop 100
+
+END_MESSAGE
+
+    print $message;
+    exit 0;
+}
+
+
+
+sub help_pulse {
+    my $message = <<'END_MESSAGE';
+
+usage: mimosis [GLOBAL OPTIONS] pulse [COMMAND OPTIONS]
+
+GLOBAL OPTIONS are:
+    -f, --fpga=FPGA      ->  Hex address of the FPGA. Defaults to 0xa000.
+    -s, --sleepval1=VAL  ->  Execute I2C commands with a pause of NUM microseconds in between.
+    -a, --singleaccess   ->  Select single access mode.
+    -c, --chipid=CHIPID  ->  Use ChIPID to address sensor.
+    -u, --uart           ->  Use UART backend in TRBNet.
+    -i, --ikf            ->  Use settings for IKF proxy.
+    -m, --mbs            ->  Set stream link for Go4analysis, like mbss://localhost:36789
+    -d, --i2cspeed=VAL   ->  Use VAL as I2C speed (default: 30).
+    -p, --printall       ->  Print all informations possible.
+    -h, --help           ->  Print this or <command> specific help.
+
+COMMAND OPTIONS are:
+        --xstart XSTART          ->  Start pulsing in x-diraction from XSTART. Default 0.
+        --xstop XSTOP            ->  Pulse in x-direction until XSTOP. Default 1023.
+        --xstep XSTEP            ->  Pulse every XSTEP pixel in x-direction. Default 1.
+        --ystart YSTART          ->  Start pulsing in y-diraction from YSTART. Default 0.
+        --ystop YSTOP            ->  Pulse in y-direction until YSTOP. Default 503.
+        --ystep YSTEP            ->  Pulse every YSTEP pixel in y-direction. Default 1.
+        --modexp=MODEXP          ->  Pulse every 2**MODEXP frames. Default 3.
+        --pixpulseAA=PIXPULSEAA  ->  MSB and LSB of PIXPULSEA_A register. Default 25.
+        --pixpulseAB=PIXPULSEAB  ->  MSB and LSB of PIXPULSEA_B register. Default 75.
+        --pixpulseDA=PIXPULSEDA  ->  MSB and LSB of PIXPULSED_A register. Default 0.
+        --pixpulseDB=PIXPULSEDB  ->  MSB and LSB of PIXPULSED_B register. Default 0.
+
+EXAMPLES:
+# Pulse 4 lines in Matrix A.
+mimosis pulse --ystart 100 --ystop 103 --xstop 127
+
+END_MESSAGE
+
+    print $message;
+    exit 0;
+}
+
+
+sub help_instr {
+    my $message = <<'END_MESSAGE';
+
+usage: mimosis [GLOBAL OPTIONS] instr INSTR
+
+GLOBAL OPTIONS are:
+    -f, --fpga=FPGA      ->  Hex address of the FPGA. Defaults to 0xa000.
+    -s, --sleepval1=VAL  ->  Execute I2C commands with a pause of NUM microseconds in between.
+    -a, --singleaccess   ->  Select single access mode.
+    -c, --chipid=CHIPID  ->  Use ChIPID to address sensor.
+    -u, --uart           ->  Use UART backend in TRBNet.
+    -i, --ikf            ->  Use settings for IKF proxy.
+    -m, --mbs            ->  Set stream link for Go4analysis, like mbss://localhost:36789
+    -d, --i2cspeed=VAL   ->  Use VAL as I2C speed (default: 30).
+    -p, --printall       ->  Print all informations possible.
+    -h, --help           ->  Print this or <command> specific help.
+
+EXAMPLES:
+# Set global reset instruction
+mimosis instr 0xe0
+
+END_MESSAGE
+
+    print $message;
+    exit 0;
+}
+
+
+
+sub help_reg {
+    my $message = <<'END_MESSAGE';
+
+usage: mimosis [GLOBAL OPTIONS] reg REGISTER VALUE
+
+GLOBAL OPTIONS are:
+    -f, --fpga=FPGA      ->  Hex address of the FPGA. Defaults to 0xa000.
+    -s, --sleepval1=VAL  ->  Execute I2C commands with a pause of NUM microseconds in between.
+    -a, --singleaccess   ->  Select single access mode.
+    -c, --chipid=CHIPID  ->  Use ChIPID to address sensor.
+    -u, --uart           ->  Use UART backend in TRBNet.
+    -i, --ikf            ->  Use settings for IKF proxy.
+    -m, --mbs            ->  Set stream link for Go4analysis, like mbss://localhost:36789
+    -d, --i2cspeed=VAL   ->  Use VAL as I2C speed (default: 30).
+    -p, --printall       ->  Print all informations possible.
+    -h, --help           ->  Print this or <command> specific help.
+
+EXAMPLES:
+# Set RUNMODE register to 0x40
+mimosis reg 0x20 0x40
+
+# Read RUNMODE register
+mimosis reg 0x20
+
+END_MESSAGE
+
+    print $message;
+    exit 0;
+}
+
+
+sub help_adc {
+  my $message = <<'END_MESSAGE';
+
+usage: mimosis adc
+
+END_MESSAGE
+
+    print $message;
+    exit 0;
+}
+
+sub help_vnc {
+    my $message = <<'END_MESSAGE';
+
+usage: mimosis vnc
+
+END_MESSAGE
+
+    print $message;
+    exit 0;
+}
+
+
 
 
 
 #global
-my ( $fpga, $a, $slow, $chipid, $uart);
+my ( $fpga,
+     $sa,
+     $sleepVal1,
+     $chipid,
+     $uart,
+     $i2cSpeed,
+     $printAll,
+     $ikf,
+     $mbsStream,
+    );
+
 
 #load
-my ( $printall_load, $printwrong_load );
+my ( $printWrongLoad );
 
-#dacscan
-my ( $ikf, $name, $imagefileonly, $cleanup_dacscan, $printall_dacscan );
+my ( $startDac,
+     $stopDac,
+     $stepDac,
+     $nameDac,
+    );
 
 #scurves
-my ( $pulseOnlySc,   $regionSc, $xSc, $ySc, $addSc, $resetSc,
-     $yStaSc,    $yEndSc,     $yStepSc,
-     $xStaSc,    $xEndSc,
-     $setStaSc,    $setEndSc,
-     $setStepSc,     $vcasnSc, $vcasnStaSc,  $vcasnEndSc,
-     $vcasnStepSc,   $setCntSc,     $yTraSc,  $printSetSc, $printDacSc,
-     $printRowSc,    $printAllSc,    $analogAlimASc,
-     $analogAlimBSc, $analogDlimASc, $analogDlimBSc, $modpulseSc );
+my (
+     $ystartSc,
+     $ystopSc,
+     $ystepSc,
+     $yspanSc,
+     $xstartSc,
+     $xstopSc,
+     $xstepSc,
+     $setstartSc,
+     $setstopSc,
+     $setstepSc,
+     $setcountSc,
+     $vcasnregSc,
+     $vcasnstartSc,
+     $vcasnstopSc,
+     $vcasnstepSc,
+     $modexpSc,
+     $modfoundSc,
+     $pixpulseAASc,
+     $pixpulseABSc,
+     $pixpulseDASc,
+     $pixpulseDBSc,
+    );
 
 #mask
-my ( $region_mask,  $row_mask,       $col_mask,
-     $maskall_mask, $unmaskall_mask, $hline_mask,
-     $vline_mask,   $square_mask,    $printall_mask );
+my ( $xstartMask,
+     $xstopMask,
+     $xstepMask,
+     $ystartMask,
+     $ystopMask,
+     $ystepMask );
+
+my ( $xstartPulse,
+     $xstopPulse,
+     $xstepPulse,
+     $ystartPulse,
+     $ystopPulse,
+     $ystepPulse,
+     $pixpulseAAPulse,
+     $pixpulseABPulse,
+     $pixpulseDAPulse,
+     $pixpulseDBPulse,
+     $modexpPulse,
+    );
+
+
 
-#analyse
-my ( $vcasnAn, $threadsAn );
 
 my @ARGV_bak = @ARGV;
 
+
 my $res = GetOptions (
+
     options => {
-        'fpga|f=s'        => \$fpga,
-        'singleaccess|a'  => \$a,
-        'slow|s=s'        => \$slow,
-        'chipid=s'        => \$chipid,
-        'uart=s'          => \$uart,
+        'fpga|f=s'        => {
+            handler => sub { Mimosis::set_fpga( hex $_[1]); }
+           },
+        'singleaccess|a'  => {
+            handler => sub { Mimosis::set_singleAccess(1); }
+           },
+        'sleepval1|s=s'        => {
+            handler => sub { Mimosis::set_sleepVal1($_[1]); }
+           },
+        'chipid|c=s'        => {
+            handler => sub { Mimosis::set_chipid($_[1]); },
+           },
+        'uart|u=s'          => {
+            handler => sub {
+                require("/d/jspc37/mimosis/scripts/TrbNetUart.pm");
+                TNU_set_device($_[1]);
+                trb_init_ports() or die trb_strerror();
+                Mimosis::make_require($_[1],$TNU_fh);
+            },
+           },
+        'i2cspeed|d=s'      => {
+            handler => sub {
+                trb_init_ports() or die trb_strerror();
+               Mimosis::set_i2cSpeed($_[1]); },
+           },
+        'printall|p'        => {
+            handler => sub { Mimosis::set_printall(1); },
+           },
+        'ikf|i'        => {
+            handler => sub { Mimosis::set_adcToIkfProxy(); },
+           },
+        'mbs|m=s'        => {
+            handler => sub { Mimosis::set_mbsStream($_[1]); },
+           },
     },
+
     default_subcommand => 'default',
+
     subcommands => {
+
         default => {},
+
         load => {
             options => {
-                'printall|p'    => \$printall_load,
-                'printwrong|w'  => \$printwrong_load,
-                'help|h'        => {
-                    handler => \&Mimosis::help_load,
-                }
+                'printwrong|w'  => \$printWrongLoad,
+                'help|h'        => { handler => \&help_load, }
             },
         },
+
         dacscan => {
             options => {
-                "ikf|i"             => \$ikf,
-                "imagefile-only|m"  => \$imagefileonly,
-                "name|n=s"          => \$name,
-                "cleanup|c"         => \$cleanup_dacscan,
-                'printall|p'        => \$printall_dacscan,
+                'start=s'       => \$startDac,
+                'stop=s'        => \$stopDac,
+                'step=s'        => \$stepDac,
+                'name=s'        => \$nameDac,
                 'help|h'        => {
-                    handler => \&Mimosis::help_dacscan,
+                    handler => \&help_dacscan,
                 }
             },
         },
+
         scurves => {
             options => {
-                "pulseonly"         => \$pulseOnlySc,
-                "region|r=s"        => \$regionSc,
-                "x=s"               => \$xSc,
-                "y=s"               => \$ySc,
-                "add"               => \$addSc,
-                "reset"             => \$resetSc,
-                "firstrow=s"        => \$yStaSc,
-                "lastrow=s"         => \$yEndSc,
-                "rowdiv=s"          => \$yStepSc,
-                "firstcol=s"        => \$xStaSc,
-                "lastcol=s"         => \$xEndSc,
-                "firstset=s"        => \$setStaSc,
-                "lastset=s"         => \$setEndSc,
-                "setdiv=s"          => \$setStepSc,
-                "setcounts=s"       => \$setCntSc,
-                "firstvcasn=s"      => \$vcasnStaSc,
-                "lastvcasn=s"       => \$vcasnEndSc,
-                "vcasndiv=s"        => \$vcasnStepSc,
-                "vcasn=s"           => \$vcasnSc,
-                "nrows=s"           => \$yTraSc,
-                "printdac"          => \$printDacSc,
-                "printset"          => \$printSetSc,
-                "printrow"          => \$printRowSc,
-                "printall|p"        => \$printAllSc,
-                "analogAlimA=s"     => \$analogAlimASc,
-                "analogAlimB=s"     => \$analogAlimBSc,
-                "analogDlimA=s"     => \$analogDlimASc,
-                "analogDlimB=s"     => \$analogDlimBSc,
-                "modpulse=s"        => \$modpulseSc,
+                'ystart=s'      => \$ystartSc,
+                'ystop=s'       => \$ystopSc,
+                'ystep=s'       => \$ystepSc,
+                'yspan=s'       => \$yspanSc,
+                'xstart=s'      => \$xstartSc,
+                'xstop=s'       => \$xstopSc,
+                'xstep=s'       => \$xstepSc,
+                'setstart=s'    => \$setstartSc,
+                'setstop=s'     => \$setstopSc,
+                'setstep=s'     => \$setstepSc,
+                'setcount=s'    => \$setcountSc,
+                'vcasnreg=s'    => \$vcasnregSc,
+                'vcasnstart=s'  => \$vcasnstartSc,
+                'vcasnstop=s'   => \$vcasnstopSc,
+                'vcasnstep=s'   => \$vcasnstepSc,
+                'modexp=s'      => \$modexpSc,
+                'modfound=s'    => \$modfoundSc,
+                'pixpulseAA=s'  => \$pixpulseAASc,
+                'pixpulseAB=s'  => \$pixpulseABSc,
+                'pixpulseDA=s'  => \$pixpulseDASc,
+                'pixpulseDB=s'  => \$pixpulseDBSc,
                 'help|h'        => {
-                    handler => \&Mimosis::help_scurves,
+                    handler => \&help_scurves,
                 }
             },
         },
-        analyse => {
+
+        mask => {
             options => {
-                "vcasn"         => \$vcasnAn,
-                "threads|t"     => \$threadsAn,
-                'help|h'        => {
-                    handler => \&Mimosis::help_analyse,
+                "xstart=s"          => \$xstartMask,
+                "xstop=s"           => \$xstopMask,
+                "xstep=s"           => \$xstepMask,
+                "ystart=s"          => \$ystartMask,
+                "ystop=s"           => \$ystopMask,
+                "ystep=s"           => \$ystepMask,
+                'help|h'            => {
+                    handler => \&help_mask,
                 }
             },
         },
-        mask => {
+
+        pulse => {
             options => {
-                "region|r=s"        => \$region_mask,
-                "row|y=s"           => \$row_mask,
-                "column|x=s"        => \$col_mask,
-                "mask-all"          => \$maskall_mask,
-                "unmask-all"        => \$unmaskall_mask,
-                "mask-all-reg"      => \$maskall_mask,
-                "unmask-all-reg"    => \$unmaskall_mask,
-                "hline"             => \$hline_mask,
-                "vline"             => \$vline_mask,
-                "square"            => \$square_mask,
-                "printall|p"        => \$printall_mask,
+                'xstart=s'          => \$xstartPulse,
+                'xstop=s'           => \$xstopPulse,
+                'xstep=s'           => \$xstepPulse,
+                'ystart=s'          => \$ystartPulse,
+                'ystop=s'           => \$ystopPulse,
+                'ystep=s'           => \$ystepPulse,
+                'pixpulseaa=s'      => \$pixpulseAAPulse,
+                'pixpulseab=s'      => \$pixpulseABPulse,
+                'pixpulseda=s'      => \$pixpulseDAPulse,
+                'pixpulsedb=s'      => \$pixpulseDBPulse,
+                'modexp=s'          => \$modexpPulse,
                 'help|h'            => {
-                    handler => \&Mimosis::help_mask,
+                    handler => \&help_pulse,
                 }
             },
         },
+
+        pixel_dump => {
+            options => {
+                'help|h'            => {
+                    handler => \&help_pixel_dump,
+                }
+            },
+        },
+
         instr => {
             options => {
                 'help|h' => {
-                    handler => \&Mimosis::help_instr,
+                    handler => \&help_instr,
                 }
             },
         },
+
         reg => {
             options => {
                 'help|h' => {
-                    handler => \&Mimosis::help_reg,
+                    handler => \&help_reg,
+                }
+            },
+        },
+
+        adc => {
+            options => {
+                'help|h' => {
+                    handler => \&help_adc,
                 }
             },
         },
+
         vnc => {
             options => {
                 'help|h' => {
-                    handler => \&Mimosis::help_vnc,
+                    handler => \&help_vnc,
                 }
             },
         },
     },
+
     completion => sub {
-        my %args = @_;
     },
 );
+
 die "GetOptions failed!\n" unless $res->{success};
 
+# if (defined $uart) {
+#     require("/d/jspc37/mimosis/scripts/TrbNetUart.pm");
+#     TNU_set_device($uart);
+#     trb_init_ports() or die trb_strerror();
+#     Mimosis::make_require($uart,$TNU_fh);
 
-if (defined $uart) {
-    require("/d/jspc37/mimosis/scripts/TrbNetUart.pm");
-    TNU_set_device($uart);
-    trb_init_ports() or die trb_strerror();
-    Mimosis::make_require($uart,$TNU_fh);
+# } else {
+#     trb_init_ports() or die trb_strerror();
+# }
 
-} else {
-    trb_init_ports() or die trb_strerror();
-}
+trb_init_ports() or die trb_strerror();
 
 
-
-if( $res->{subcommand}[0] eq 'default' )
-{
-    Mimosis::help_global();
+if( $res->{subcommand}[0] eq 'default' ) {
+    help_global();
     exit;
 }
 
 
-my $daqopserver = $ENV{'DAQOPSERVER'};
-if ( !defined $daqopserver || $daqopserver eq '' || ( $daqopserver ne 'jspc29:31' && $daqopserver ne 'jspc29:150' ) )
-{
-    print "\nDAQOPSERVER not defined or wrong value.\n";
-    print("Which setup?\n");
-    print("1  Lab317\n");
-    print("2  Probestation\n");
-    print("Choose [1,2]: ");
-    my $choise = <STDIN>;
-    chomp $choise;
-
-    if( $choise ne '2' and $choise ne '1' )
-    {
-        print("Not a valid input.\n");
-    }
-    elsif( $choise eq '1' )
-    {
-        $daqopserver = 'jspc29:150';
-    }
-    elsif( $choise eq '2' )
-    {
-        $daqopserver = 'jspc29:31';
-    }
-    $ENV{'DAQOPSERVER'} = $daqopserver;
-    do "mimosis " . join( " ", @ARGV_bak );
-}
-
 
 
 
-$fpga = defined($fpga) ? hex $fpga : 0xa000;
-$slow = defined($slow) ? $slow : 10000;
-$chipid = defined($chipid) ? hex $chipid: 0x1;
+if( $res->{subcommand}[0] eq 'load' ) {
 
-Mimosis::set_chipid($chipid);
+    if( defined $ARGV[-1] && -e $ARGV[-1]) {
 
+        Mimosis::mimosis_load_file(
+            file        => $ARGV[-1],
+            printwrong  => $printWrongLoad,
+           );
 
-if( $res->{subcommand}[0] eq 'load' )
-{
-    if( defined $ARGV[-1] && -e $ARGV[-1])
-    {
-        $file = $ARGV[-1];
-    }
-    else
-    {
-        print "No valid file provided.\n";
-        exit 1;
+    } else {
+        die "No valid file provided.\n";
     }
 
-    Mimosis::mimosis_load_file(
-        fpga        => $fpga,
-        file        => $file,
-        printall    => $printall_load,
-        printwrong  => $printwrong_load,
-        slow        => $slow,
-        a           => $a
-        );
-}
+} elsif( $res->{subcommand}[0] eq 'dacscan' ) {
 
-elsif( $res->{subcommand}[0] eq 'dacscan' )
-{
     Mimosis::mimosis_dacscan(
-        fpga            => $fpga,
-        slow            => $slow,
-        a               => $a,
-        ikf             => $ikf,
-        name            => $name,
-        cleanup         => $cleanup_dacscan,
-        imagefileonly   => $imagefileonly,
-        printall        => $printall_dacscan,
+      start => $startDac,
+      stop  => $stopDac,
+      step  => $stepDac,
+      name  => $nameDac,
+      dacs  => \@ARGV
+   );
+
+} elsif( $res->{subcommand}[0] eq 'scurves' ) {
+
+    Mimosis::mimosis_scurves (
+        ystart      => $ystartSc,
+        ystop       => $ystopSc,
+        ystep       => $ystepSc,
+        yspan       => $yspanSc,
+
+        xstart      => $xstartSc,
+        xstop       => $xstopSc,
+        xstep       => $xstepSc,
+
+        setstart    => $setstartSc,
+        setstop     => $setstopSc,
+        setstep     => $setstepSc,
+        setcount    => $setcountSc,
+
+        vcasnreg    => $vcasnregSc,
+        vcasnstart  => $vcasnstartSc,
+        vcasnstop   => $vcasnstopSc,
+        vcasnstep   => $vcasnstepSc,
+
+        pixpulseaa  => $pixpulseAASc,
+        pixpulseab  => $pixpulseABSc,
+        pixpulseda  => $pixpulseDASc,
+        pixpulsedb  => $pixpulseDBSc,
+
+        modexp      => $modexpSc,
+        modfound    => $modfoundSc,
         );
-}
 
-elsif( $res->{subcommand}[0] eq 'scurves' )
-{
+} elsif( $res->{subcommand}[0] eq 'pixel_dump' ) {
+
+    die "No instruction provided.\n"
+      unless defined $ARGV[-1];
+
+    Mimosis::mimosis_pixel_dump(
+       Mimosis::get_fpga(),
+       hex $ARGV[-1]
+       );
+
 
-    my %regCharToStr = (
-        A => 'VCASNA',
-        B => 'VCASNB',
-        C => 'VCASNC',
-        D => 'VCASND'
+} elsif( $res->{subcommand}[0] eq 'mask' ) {
+
+    Mimosis::mimosis_mask(
+        xstart => $xstartMask,
+        xstop  => $xstopMask,
+        xstep  => $xstepMask,
+        ystart => $ystartMask,
+        ystop  => $ystopMask,
+        ystep  => $ystepMask,
         );
 
-    if( defined $pulseOnlySc )
-    {
-        Mimosis::mimosis_pulse_region(
-            fpga        => $fpga,
-            slow        => $slow,
-            a           => $a,
-            region      => $regionSc,
-            ySta        => $yStaSc,
-            yEnd        => $yEndSc,
-            yTra        => $yTraSc,
-            xSta        => $xStaSc,
-            xEnd        => $xEndSc,
-            analogAlimA => $analogAlimASc,
-            analogAlimB => $analogAlimBSc,
-            analogDlimA => $analogDlimASc,
-            analogDlimB => $analogDlimBSc,
-            mod         => $modpulseSc,
+} elsif( $res->{subcommand}[0] eq 'pulse' ) {
+
+    Mimosis::mimosis_pulse(
+        xstart => $xstartPulse,
+        xstop  => $xstopPulse,
+        xstep  => $xstepPulse,
+        ystart => $ystartPulse,
+        ystop  => $ystopPulse,
+        ystep  => $ystepPulse,
+        pixpulseaa  => $pixpulseAAPulse,
+        pixpulseab  => $pixpulseABPulse,
+        pixpulseda  => $pixpulseDAPulse,
+        pixpulsedb  => $pixpulseDBPulse,
+        modexp      => $modexpPulse,
         );
-        exit 0;
-    }
 
-    if( defined $regionSc )
-    {
-        Mimosis::mimosis_scan_region_loop(
-            fpga        => $fpga,
-            slow        => $slow,
-            a           => $a,
-            region      => $regionSc,
-            vcasnSta    => $vcasnStaSc,
-            vcasnEnd    => $vcasnEndSc,
-            vcasnStep   => $vcasnStepSc,
-            ySta        => $yStaSc,
-            yEnd        => $yEndSc,
-            yTra        => $yTraSc,
-            xSta        => $xStaSc,
-            xEnd        => $xEndSc,
-            setSta      => $setStaSc,
-            setEnd      => $setEndSc,
-            setTra      => $setStepSc,
-            setCnt      => $setCntSc,
-            analogAlimA => $analogAlimASc,
-            analogAlimB => $analogAlimBSc,
-            analogDlimA => $analogDlimASc,
-            analogDlimB => $analogDlimBSc,
-            mod         => $modpulseSc,
-            );
-
-        exit 0;
-
-        # my $vcasnStr = $regCharToStr{$regionSc};
-        # my $vcasnVal = Mimosis::mimosis_register_read( $fpga, $dacs{$vcasnStr}, $a );
-        # $vcasnStaSc = defined $vcasnStaSc ? $vcasnStaSc : $vcasnVal;
-        # $vcasnEndSc = defined $vcasnEndSc ? $vcasnEndSc : $vcasnStaSc;
-        # $vcasnStepSc = defined $vcasnStepSc ? $vcasnStepSc : 1;
-
-        # system("/d/jspc37/mimosis/cpp/build/scurve-scan mbss://localhost:36789 &");
-
-        # for ( my $vcasnSet = $vcasnStaSc;
-        #       $vcasnSet <= $vcasnEndSc;
-        #       $vcasnSet += $vcasnStepSc ) {
-        #     #set vcasn
-        #     Mimosis::mimosis_register_write( $fpga, $dacs{$vcasnStr}, $vcasnSet, $a ); usleep($slow);
-
-        #     if( $printDacSc || $printAllSc ) { printf("dac: $vcasnSet\n"); }
-
-        #     Mimosis::mimosis_scan_region(
-        #         fpga        => $fpga,
-        #         slow        => $slow,
-        #         a           => $a,
-        #         region      => $regionSc,
-        #         ySta        => $yStaSc,
-        #         yEnd        => $yEndSc,
-        #         yTra        => $yTraSc,
-        #         xSta        => $xStaSc,
-        #         xEnd        => $xEndSc,
-        #         setSta      => $setStaSc,
-        #         setEnd      => $setEndSc,
-        #         setTra      => $setStepSc,
-        #         setCnt      => $setCntSc,
-        #         analogAlimA => $analogAlimASc,
-        #         analogAlimB => $analogAlimBSc,
-        #         analogDlimA => $analogDlimASc,
-        #         analogDlimB => $analogDlimBSc,
-        #         mod         => $modpulseSc,
-        #     );
-
-        #     Mimosis::send_params_scurve(
-        #                                 state => "FIT",
-        #                                 region => $regCharToStr{$regionSc},
-        #                                 vcasn => $vcasnSet
-        #                                );
-        #     Mimosis::await_ack();
-        # }
-
-        # Mimosis::send_params_scurve( state => "DONE" );
-        # Mimosis::await_ack();
-        # Mimosis::kill_proc_by_pid_file("/tmp/hldprint-pid");
-        # exit 0;
-
-    } elsif (defined $xSc && defined $ySc && defined $vcasnSc) {
-
-        # my $vcasnVal = Mimosis::mimosis_register_read( $fpga, $dacs{$vcasnSc}, $a );
-        # $vcasnStaSc = defined $vcasnStaSc ? $vcasnStaSc : $vcasnVal;
-        # $vcasnEndSc = defined $vcasnEndSc ? $vcasnEndSc : $vcasnStaSc;
-        # $vcasnStepSc = defined $vcasnStepSc ? $vcasnStepSc : 1;
-
-        # unless($pulseOnlySc)
-        # {
-        #     system("/d/jspc37/mimosis/cpp/build/scurve-scan mbss://localhost:36789 &");
-        # }
-
-        # for ( my $vcasnSet = $vcasnStaSc;
-        #       $vcasnSet <= $vcasnEndSc;
-        #       $vcasnSet += $vcasnStepSc ) {
-        #     #set vcasn
-        #     Mimosis::mimosis_register_write( $fpga, $dacs{$vcasnSc}, $vcasnSet, $a ); usleep($slow);
-
-        #     if( $printDacSc || $printAllSc ) { printf("dac: $vcasnSet\n"); }
-
-        #     Mimosis::mimosis_scan_pixel(
-        #         fpga        => $fpga,
-        #         slow        => $slow,
-        #         a           => $a,
-        #         x           => $xSc,
-        #         y           => $ySc,
-        #         pulseonly   => $pulseOnlySc,
-        #         firstset    => $setStaSc,
-        #         lastset     => $setEndSc,
-        #         setdiv      => $setStepSc,
-        #         settime     => $setCntSc,
-        #         printset    => $printSetSc,
-        #         printrow    => $printRowSc,
-        #         printall    => $printAllSc,
-        #         analogAlimA => $analogAlimASc,
-        #         analogAlimB => $analogAlimBSc,
-        #         analogDlimA => $analogDlimASc,
-        #         analogDlimB => $analogDlimBSc,
-        #         modpulse    => $modpulseSc,
-        #     );
-
-        #     unless($pulseOnlySc)
-        #     {
-        #         Mimosis::send_params_scurve("FIT", 0,0,0,0,$vcasnSc,$vcasnSet);
-        #         Mimosis::await_ack();
-        #     }
-        # }
-
-        # unless($pulseOnlySc)
-        # {
-        #     Mimosis::send_params_scurve("DONE", 0,0,0,0,0,0);
-        #     Mimosis::await_ack();
-        #     Mimosis::kill_proc_by_pid_file("/tmp/hldprint-pid");
-        # }
-        # exit 0;
+} elsif( $res->{subcommand}[0] eq 'instr' ) {
 
-    } else {
+    die "No instruction provided.\n"
+      unless defined $ARGV[-1];
 
-        print "Mimosis::mimosis_scan_region: Must provide --region A|B|C|D or --x X and --y Y.\n";
-        exit 1;
-    }
-}
+    Mimosis::mimosis_instr_write( hex $ARGV[-1] );
+
+} elsif( $res->{subcommand}[0] eq 'reg' ) {
 
-elsif( $res->{subcommand}[0] eq 'analyse' )
-{
-    open(FH, '<', 'METADATA') or die print "Cannot open METADATA. Is this a vild run dir?\n";
+    if( defined $ARGV[-2] ) {
 
-    while(<FH>){
-        print $_;
+        Mimosis::mimosis_register_write(
+            hex $ARGV[-2],
+            hex $ARGV[-1],
+           );
+
+    } elsif( defined $ARGV[-1] &&
+             not defined $ARGV[-2] ) {
+
+        printf( "%x\n",
+                Mimosis::mimosis_register_read( hex $ARGV[-1] ));
     }
 
-    # system("/d/jspc37/mimosis/scripts/pulse/plot-raw.py");
+} elsif( $res->{subcommand}[0] eq 'adc' ) {
 
-    exit 0;
-}
+    my $adc_addr = 0x48;
+    my $adc_wreg = 0x1;
+    my $adc_rreg = 0x0;
+    my $adc_data = hex $ARGV[-1];
 
-elsif( $res->{subcommand}[0] eq 'mask' )
-{
-    Mimosis::mimosis_mask(
-        fpga        => $fpga,
-        region      => $region_mask,
-        row         => $row_mask,
-        col         => $col_mask,
-        maskall     => $maskall_mask,
-        unmaskall   => $unmaskall_mask,
-        hline       => $hline_mask,
-        vline       => $vline_mask,
-        square      => $square_mask,
-        printall    => $printall_mask,
-        );
-}
+    if( defined $ARGV[-1] ) {
 
-elsif( $res->{subcommand}[0] eq 'instr' )
-{
-    if( defined $ARGV[-1] )
-    {
-        Mimosis::mimosis_instr_write( $fpga, hex($ARGV[-1]) );
-    }
-    else
-    {
-        print "No instruction provided.\n";
-    }
-    exit 1;
-}
+        printf("Write to ADC: 0x%04x\n", $adc_data);
 
-elsif( $res->{subcommand}[0] eq 'reg' )
-{
-    my $reg_reg;
-    my $data_reg;
+        Mimosis::adc_i2c_command (
+            $adc_addr,
+            $adc_wreg,
+            $adc_data,
+            0, 0, 1
+           );
 
-    if( defined $ARGV[-2] )
-    {
-        $reg_reg = hex $ARGV[-2];
-        $data_reg = hex $ARGV[-1];
-        Mimosis::mimosis_register_write( $fpga, $reg_reg, $data_reg, $a );
-    }
-    elsif( defined $ARGV[-1] && not defined $ARGV[-2] )
-    {
-        $reg_reg = hex $ARGV[-1];
-        printf( "%x\n", Mimosis::mimosis_register_read( $fpga, $reg_reg, $a ) );
+    } else {
+
+       my $adcConv = ( 2 * 4096 ) / 2**16;
+
+        # printf( "0x%04x\n",
+        printf( "%f\n",
+                Mimosis::adc_i2c_command(
+                  $adc_addr,
+                  $adc_rreg,
+                  0,
+                  1,0,1
+               )*$adcConv
+           );
     }
-    exit 1;
-}
 
-elsif( $res->{subcommand}[0] eq 'vnc' )
-{
-    print("Which setup?\n");
-    print("1  Lab317\n");
-    print("2  Probestation\n");
-    print("Choose [1,2]: ");
-    my $choise = <STDIN>;
-    my $daqopserver;
+} elsif( $res->{subcommand}[0] eq 'vnc' ) {
+
+    my $dos;
     my $display;
+    my $choice;
+
+    do {
+        print("Which vnc?\n");
+        print("1  Lab317\n");
+        print("2  Probestation\n");
+        print("3  Lab318\n");
+        print("Choose [1,2,3]: ");
+
+        $choice = <STDIN>;
+        chomp $choice;
+
+        if( $choice != 2 and
+            $choice != 1 and
+           $choice != 3 ) {
+
+            print("Not a valid input.\n");
+
+        } elsif( $choice == 1 ) {
+
+            $dos = 'jspc29:150';
+            $display = ':2';
+
+        } elsif( $choice == 2 ) {
+
+            $dos = 'jspc29:109';
+            $display = ':5';
+
+        } elsif( $choice == 3 ) {
+
+            $dos = 'jspc29:7';
+            $display = ':7';
+        }
+    } while( $choice != 1 and
+             $choice != 2 and
+            $choice != 3 );
 
-    if( $choise != 2 and $choise != 1 )
-    {
-        print("Not a valid input.\n");
-    }
-    elsif( $choise == 1 )
-    {
-        $daqopserver = 'jspc29:150';
-        $display = ':2';
-    }
-    elsif( $choise == 2 )
-    {
-        $daqopserver = 'jspc29:31';
-        $display = ':5';
-    }
 
-    my $val = `ssh jspc37 'ps aux | grep Xvnc'`;
     my $yesno;
-    if( $val =~ /Xvnc $display -auth \/u\/maps\/.Xauthority -desktop jspc37$display/ )
-    {
-        print "kill old vncserver? [y/n]: ";
-        $yesno = <STDIN>;
-        chomp $yesno;
-        if($yesno != "y" && $yesno != "n")
-        {
-            print "Not a valid input.\n";
+    my $val = `ssh jspc37 'ps aux | grep Xvnc'`;
+
+    if( $val =~ /Xvnc $display -auth \/u\/maps\/.Xauthority -desktop jspc37$display/ ) {
+
+        do {
+            print "kill old vncserver? [y/n]: ";
+            $yesno = <STDIN>;
+            chomp $yesno;
+
+            if($yesno ne "y" &&
+               $yesno ne "n") {
+
+                print "Not a valid input.\n";
+            }
+        } while ( $yesno ne "y" &&
+                  $yesno ne "n");
+
+
+        if($yesno eq "y") {
+
+            system("ssh jspc37 '/d/salt/bin/vncserver -kill $display'");
+            sleep(3);
+            system("ssh jspc37 '/d/salt/bin/vncserver $display' &");
+            sleep(1);
+
+            if ($pid = fork) {
+
+            } else {
+
+                close (STDOUT);
+                system("vncviewer jspc37$display -shared -passwd ~/.passfile_for_vnc");
+                exit 0;
+            }
+
+            system("ssh jspc37 'DISPLAY=$display DAQOPSERVER=$dos konsole --tabs-from-file /u/maps/.konsole.tabs' &");
+            sleep(6);
+            system("ssh jspc37 'DISPLAY=$display DAQOPSERVER=$dos /d/jspc37/mimosis/scripts/start.sh'");
+
+        } else {
+
+            if ($pid = fork) {
+
+            } else {
+
+                close (STDOUT);
+                system("vncviewer jspc37$display -shared -passwd ~/.passfile_for_vnc");
+                exit 0;
+            }
         }
-    }
-    else
-    {
-        $yesno = "y";
-    }
-    if($yesno eq "y")
-    {
-        system("ssh jspc37 '/d/salt/bin/vncserver -kill $display'");
-        sleep(3);
+
+    } else {
+
         system("ssh jspc37 '/d/salt/bin/vncserver $display' &");
         sleep(1);
-        if ($pid = fork) {}
-        else
-        {
-            close (STDOUT);
-            system("vncviewer jspc37$display -shared -passwd ~/.passfile_for_vnc");
-            exit(0);
-        }
-        # sleep(1);
-        # system("ssh jspc37 'firefox -p Lab317 --display=$display' &");
-        system("ssh jspc37 'DISPLAY=$display DAQOPSERVER=$daqopserver konsole --tabs-from-file /u/maps/.konsole.tabs' &");
-        sleep(10);
-        system("ssh jspc37 'DISPLAY=$display DAQOPSERVER=$daqopserver /d/jspc37/mimosis/scripts/start.sh'");
-    }
-    else
-    {
-        if ($pid = fork) {}
-        else
-        {
+
+        if ($pid = fork) {
+
+        } else {
+
             close (STDOUT);
             system("vncviewer jspc37$display -shared -passwd ~/.passfile_for_vnc");
-            exit(0);
+            exit 0;
         }
+
+        system("ssh jspc37 'DISPLAY=$display DAQOPSERVER=$dos konsole --tabs-from-file /u/maps/.konsole.tabs' &");
+        sleep(6);
+        system("ssh jspc37 'DISPLAY=$display DAQOPSERVER=$dos /d/jspc37/mimosis/scripts/start.sh'");
     }
 }