From 97ed733b985dc7222eb75f4f890d181f86db47ae Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 13 Apr 2017 15:43:55 +0200 Subject: save voltage(s) in model files --- lib/Kratos/DFADriver.pm | 2 ++ lib/Kratos/DFADriver/Model.pm | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) (limited to 'lib/Kratos') diff --git a/lib/Kratos/DFADriver.pm b/lib/Kratos/DFADriver.pm index 321860d..83a572f 100644 --- a/lib/Kratos/DFADriver.pm +++ b/lib/Kratos/DFADriver.pm @@ -644,6 +644,8 @@ sub update_model { } } + $self->model->set_voltage($self->{log}{aggregate}{min_voltage}, $self->{log}{aggregate}{max_voltage}); + $self->model->save; } diff --git a/lib/Kratos/DFADriver/Model.pm b/lib/Kratos/DFADriver/Model.pm index ef821e7..18bccfe 100644 --- a/lib/Kratos/DFADriver/Model.pm +++ b/lib/Kratos/DFADriver/Model.pm @@ -412,6 +412,22 @@ sub set_transition_params { } } +sub set_voltage { + my ($self, $min_voltage, $max_voltage) = @_; + + my ($data_node) = $self->xml->findnodes('/data'); + + for my $voltage_node ($data_node->findnodes('./voltage')) { + $data_node->removeChild($voltage_node); + } + + my $voltage_node = XML::LibXML::Element->new('voltage'); + $voltage_node->setAttribute('min', $min_voltage); + $voltage_node->setAttribute('max', $max_voltage); + + $data_node->appendChild($voltage_node); +} + sub save { my ($self) = @_; -- cgit v1.2.3