diff options
author | Daniel Friesel <derf@finalrewind.org> | 2017-05-18 09:48:07 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2017-05-18 09:48:07 +0200 |
commit | 8b41795516bd3d54dedaf1eadc04731ad6c4febb (patch) | |
tree | 41ab6ccc879b3cf729fa8c0fe668b3d0ea2e4fe6 | |
parent | 4da867e42eca6264ca59a6ac999f49aa684385ba (diff) |
Fix JSON generation from class/attributes
-rw-r--r-- | lib/Kratos/DFADriver/Model.pm | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/Kratos/DFADriver/Model.pm b/lib/Kratos/DFADriver/Model.pm index ea5e297..3eb89e1 100644 --- a/lib/Kratos/DFADriver/Model.pm +++ b/lib/Kratos/DFADriver/Model.pm @@ -54,14 +54,14 @@ sub new_from_repo { my $repo = $opt{repo}; my $self = { - class => $opt{class_name}, + class_name => $opt{class_name}, model_file => $opt{model_file}, voltage => {}, }; bless( $self, $class ); - my $class_name = $self->{class}; + my $class_name = $self->{class_name}; my @states; my %transition; @@ -81,6 +81,9 @@ sub new_from_repo { push( @states, $attrib ); push( @{ $transition{ $function->{name} }{dst} }, $attrib ); } + elsif ( $attrib =~ m{ ^ epilogue $ }x ) { + $transition{ $function->{name} }{level} = 'epilogue'; + } else { say "wat $attrib"; } @@ -92,7 +95,10 @@ sub new_from_repo { for my $i ( 0 .. $#states ) { $self->{state}{ $states[$i] } = { - id => $i, + id => $i, + power => { + static => 0, + } }; } @@ -100,10 +106,13 @@ sub new_from_repo { for my $i ( 0 .. $#transition_names ) { my $name = $transition_names[$i]; + my $guess_level = ( $name eq 'epilogue' ? 'epilogue' : 'user' ); $self->{transition}{$name} = { + name => $name, id => $i, destination => $transition{$name}{dst}[0], origins => $transition{$name}{src}, + level => $transition{$name}{level} // $guess_level, }; } |