|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
本帖最后由 sally8512152 于 2012-10-31 01:11 编辑
package SET;
my @checker;
my $deep;
sub new {
my $class = shift;
my $name = shift @_;
my $type = shift @_;
my $point_op_set_name = shift @_;
my $point_op_dcd_name = shift @_;
my $point_op_dcd_value = shift @_;
my $point_op_dcd_len = shift @_;
my $point_op_dcd_orint = shift @_;
my $worksheet = shift @_;
my @op_set_name = @$point_op_set_name;
my @op_dcd_name = @$point_op_dcd_name;
my @op_dcd_value = @$point_op_dcd_value;
my %op_dcd_len = %$point_op_dcd_len;
my %op_dcd_orint = %$point_op_dcd_orint;
my $ref = { "Name" => $name,
"Type" => $type,
"P_op_set_name" => \@op_set_name,
"P_op_dcd_name" => \@op_dcd_name,
"P_op_dcd_value" => \@op_dcd_value,
"P_op_dcd_len" => \%op_dcd_len,
"P_op_dcd_orint" => \%op_dcd_orint
};
bless($ref);
return $ref;
}
sub clear {
my $self = shift;
while(my ($key,$value) = each %{$self->{"P_op_dcd_len"}}){
$deep += $value;
}
print "deep = $deep\n";
@checker = ''; #clear the @checker for new set
for(my $i=0;$i<(2**$deep);$i++){ #initial the @checker
$checker[$i] = 0;
}
}
sub build{
my $self = shift;
my @op_dcd_name = @{$self->{"P_op_dcd_name"}};
my @op_dcd_value = @{$self->{"P_op_dcd_value"}};
my %op_dcd_orint = %{$self->{"P_op_dcd_orint"}};
my %op_dcd_len = %{$self->{"P_op_dcd_len"}};
my %op_dcd_value_num;
my %op_big_value_array;
my @check_bin;
my $check_num = 1;
foreach my $name (@{$self->{"P_op_dcd_name"}}){
if($op_dcd_value[$op_dcd_orint{$name}] eq 'z'){
print "$name value is,",$op_dcd_value[$op_dcd_orint{$name}],"\n";
for(my $i=0;$i<2**($op_dcd_len{$name});$i++){
#$op_big_value_array->{$name}->{$i}=$i;
$op_big_value_array->{$name}->{0}="00";
$op_big_value_array->{$name}->{1}="01";
$op_big_value_array->{$name}->{2}="10";
$op_big_value_array->{$name}->{3}="11";
$op_dcd_value_num{$name} =2**($op_dcd_len{$name});
}
#for(my $i=0;$i<2**($op_dcd_len{$name});$i++){
# print $i,"=",$op_big_value_array->{$name}->{$i}=$i,"\n";
#}
}
elsif($op_dcd_value[$op_dcd_orint{$name}] =~ /[\d,x]+/i){
if($op_dcd_value[$op_dcd_orint{$name}] =~ /x+/i){
print "$name value has x,",$op_dcd_value[$op_dcd_orint{$name}],"\n";
#from x_change function
$op_big_value_array->{$name}->{0}=101;
$op_big_value_array->{$name}->{1}=111;
$op_dcd_value_num{$name} =2;
}
else{
print "$name value is num only,",$op_dcd_value[$op_dcd_orint{$name}],"\n";
$op_big_value_array->{$name}->{0}=1;
$op_dcd_value_num{$name} =1;
}
}
else{
die("Error: Value format is wrong!\n");
}
#my %tmp = %{$op_big_value_array->{$name}};
while( my ($key,$value) = each %{$op_big_value_array->{$name}}){
print "key=$key , value=$value\n";
}
$check_num *= $op_dcd_value_num{$name};
print "total num = $check_num\n";
}
my $name_num = 0;
foreach my $name (@{$self->{"P_op_dcd_name"}}){
my $offset = 0;
my $line_0 = 0;
if($name_num == 0){
while($op_big_value_array->{$name}->{$line_0} ne ''){
$check_bin[$line_0] = $op_big_value_array->{$name}->{$line_0};
$line_0++;
}
$name_num = 1;
}
else{
my @tem_arr;
foreach my $v_0 (@check_bin){
my $line_1 = 0;
print "2========",$op_big_value_array->{$name}->{0},"==========================\n";
while($op_big_value_array->{$name}->{$line_1} ne ''){
$tem_arr[$line_1+$offset] = "$v_0"."$op_big_value_array->{$name}->{$line_1}";
print "tem[",$line_1+$offset,"] =",$tem_arr[$line_1+$offset],"\n";
$line_1++;
}
$line_0++;
$offset = $line_0*$line_1;
}
@check_bin = @tem_arr;
}
my $i =0;
foreach my $v_0 (@check_bin){
print "check_bin[$i] =",$check_bin[$i],"\n";
$i++
}
}
}
1 |
|