<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#! /usr/bin/perl
package PerlACE::TestTarget_WinCE;

# ******************************************************************
# Description : Creates a PerlACE::WinCE
# Author      : Johnny Willemsen
# Create Date : 29/20/2008
# $Id: TestTarget_WinCE.pm 95741 2012-05-12 11:06:28Z johnnyw $
# ******************************************************************

# ******************************************************************
# Pragma Section
# ******************************************************************

use strict;

use PerlACE::TestTarget;
use PerlACE::ProcessVX;
use File::Copy;
use Cwd;
use English;

our @ISA = qw(PerlACE::TestTarget);

sub new
{
    my $proto = shift;
    my $config_name = shift;
    my $class = ref ($proto) || $proto;
    my $self = {};
    bless ($self, $class);
    $self-&gt;GetConfigSettings($config_name);
    my $targethost;
    my $env_name = $config_name.'_IPNAME';
    if (exists $ENV{$env_name}) {
        $targethost = $ENV{$env_name};
    }
    else {
        print STDERR "You must define target hostname/IP with $env_name\n";
        undef $self;
        return undef;
    }

    $env_name = $config_name.'_FS_ROOT';
    my $fsroot = '\network\temp\ACE\wince6';
    if (exists $ENV{$env_name}) {
        $fsroot = $ENV{$env_name};
    }
    else {
        print STDERR "Warning: no $env_name variable; falling back ",
                     "to $fsroot\n";
    }
    $self-&gt;{FSROOT} = $fsroot;

    $self-&gt;{REBOOT_CMD} = $ENV{'ACE_REBOOT_LVRT_CMD'};
    if (!defined $self-&gt;{REBOOT_CMD}) {
        $self-&gt;{REBOOT_CMD} = 'I_Need_A_Reboot_Command';
    }
    $self-&gt;{REBOOT_TIME} = $ENV{'ACE_LVRT_REBOOT_TIME'};
    if (!defined $self-&gt;{REBOOT_TIME}) {
        $self-&gt;{REBOOT_TIME} = 200;
    }

    $self-&gt;{REBOOT_TIME} = $ENV{'ACE_RUN_LVRT_REBOOT_TIME'};
    if (!defined $self-&gt;{REBOOT_TIME}) {
        $self-&gt;{REBOOT_TIME} = 200;
    }
    $self-&gt;{REBOOT_NEEDED} = undef;

    my $telnet_port = $ENV{'ACE_RUN_VX_TGT_TELNET_PORT'};
    my $telnet_host = $ENV{'ACE_RUN_VX_TGT_TELNET_HOST'};
    if (!defined $telnet_host)  {
      $telnet_host = $ENV{'ACE_RUN_VX_TGTHOST'};
    }
    if (!defined $telnet_port)  {
      $telnet_port = 23;
    }
    if (!defined $self-&gt;{HOST_ROOT})  {
      $self-&gt;{HOST_ROOT} = $self-&gt;{FSROOT};
    }

    $PerlACE::ProcessVX::ExeExt = '.exe';

    return $self;
}

# ******************************************************************
# Subroutine Section
# ******************************************************************

sub LocalFile {
    my $self = shift;
    my $file = shift;
    my $cwdrel = $file;
    my $prjroot = defined $ENV{'ACE_RUN_VX_PRJ_ROOT'} ? $ENV{'ACE_RUN_VX_PRJ_ROOT'}  : $ENV{'ACE_ROOT'};
    if (length ($cwdrel) &gt; 0) {
        $cwdrel = File::Spec-&gt;abs2rel( cwd(), $prjroot );
    }
    else {
        $cwdrel = File::Spec-&gt;abs2rel( $cwdrel, $prjroot );
    }
    my $newfile = $self-&gt;{FSROOT} . "/" . $cwdrel . "/" . $file;
    if (defined $ENV{'ACE_TEST_VERBOSE'}) {
      print STDERR "WinCE LocalFile for $file is $newfile\n";
    }
    return $newfile;
}

sub AddLibPath ($)
{
    my $self = shift;
    my $dir = shift;
    if (defined $ENV{'ACE_TEST_VERBOSE'}) {
        print STDERR "Adding libpath $dir\n";
    }
    PerlACE::add_lib_path ($dir);
}

sub CreateProcess
{
    my $self = shift;
    if ($OSNAME eq "MSWin32") {
        my $process = new PerlACE::ProcessVX ($self, @_);  return $process;
    } else {
        my $process = new PerlACE::ProcessVX (@_, $self);  return $process;
    }
}

# Need a reboot when this target is destroyed.
sub NeedReboot ($)
{
    my $self = shift;
    $self-&gt;{REBOOT_NEEDED} = 1;
}

# Reboot target
sub RebootNow ($)
{
    my $self = shift;
    $self-&gt;{REBOOT_NEEDED} = undef;
    print STDERR "Attempting to reboot target...\n";
    reboot ();
}

sub WaitForFileTimed ($)
{
    my $self = shift;
    my $file = shift;
    my $timeout = shift;
    my $cwdrel = $file;
    my $prjroot = defined $ENV{'ACE_RUN_VX_PRJ_ROOT'} ? $ENV{'ACE_RUN_VX_PRJ_ROOT'}  : $ENV{'ACE_ROOT'};
    if (length ($cwdrel) &gt; 0) {
        $cwdrel = File::Spec-&gt;abs2rel( cwd(), $prjroot );
    }
    else {
        $cwdrel = File::Spec-&gt;abs2rel( $cwdrel, $prjroot );
    }
    my $newfile = $self-&gt;{HOST_ROOT} . "/" . $cwdrel . "/" . $file;
    if (defined $ENV{'ACE_TEST_VERBOSE'}) {
        print STDERR "WinCE waits for $newfile timeout $timeout\n";
    }
    return PerlACE::waitforfile_timed ($newfile, $timeout);
}

# Put file from a to b
sub PutFile ($)
{
    my $self = shift;
    my $src = shift;
    return 0;
}

sub DeleteFile ($)
{
    my $self = shift;
    my $file = shift;
    my $newfile = $self-&gt;LocalFile($file);
    if (defined $ENV{'ACE_TEST_VERBOSE'}) {
        print STDERR "delete $newfile\n";
    }
    unlink ("$newfile");
}

sub KillAll ($)
{
    my $self = shift;
    my $procmask = shift;
    PerlACE::ProcessVX::kill_all ($procmask, $self);
}

1;
</pre></body></html>