Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FormerLurker/ArcWelderLib.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFormerLurker <hochgebe@gmail.com>2020-11-16 18:00:56 +0300
committerFormerLurker <hochgebe@gmail.com>2020-11-16 18:00:56 +0300
commit0f57a03f82a555a9b6d3afdfb133457c72455d54 (patch)
treeb5403a38d5ecd473f727b34e48099c9e35ba320c /GcodeProcessorLib
parentb995df6e38d0185f32f06cac87e781249975b738 (diff)
Add the job guid to the py arguments and progress updates. Add additional progress data.
Diffstat (limited to 'GcodeProcessorLib')
-rw-r--r--GcodeProcessorLib/utilities.cpp11
-rw-r--r--GcodeProcessorLib/utilities.h1
2 files changed, 11 insertions, 1 deletions
diff --git a/GcodeProcessorLib/utilities.cpp b/GcodeProcessorLib/utilities.cpp
index d126755..6ff083f 100644
--- a/GcodeProcessorLib/utilities.cpp
+++ b/GcodeProcessorLib/utilities.cpp
@@ -229,6 +229,15 @@ std::string utilities::center(std::string input, int width)
return std::string(left_padding, ' ') + input + std::string(right_padding, ' ');
}
+double utilities::get_percent_change(int v1, int v2)
+{
+ if (v1 != 0)
+ {
+ return (((double)v2 - (double)v1) / (double)v1) * 100.0;
+ }
+ return 0;
+}
+
std::string utilities::get_percent_change_string(int v1, int v2, int precision)
{
std::stringstream format_stream;
@@ -247,7 +256,7 @@ std::string utilities::get_percent_change_string(int v1, int v2, int precision)
}
else
{
- double percent_change = (((double)v2 - (double)v1) / (double)v1) * 100.0;
+ double percent_change = get_percent_change(v1, v2);
format_stream << std::fixed << std::setprecision(precision) << percent_change << "%";
}
return format_stream.str();
diff --git a/GcodeProcessorLib/utilities.h b/GcodeProcessorLib/utilities.h
index b1fc7a3..f93ac53 100644
--- a/GcodeProcessorLib/utilities.h
+++ b/GcodeProcessorLib/utilities.h
@@ -49,6 +49,7 @@ public:
static std::string trim(const std::string& s);
static std::istream& safe_get_line(std::istream& is, std::string& t);
static std::string center(std::string input, int width);
+ static double get_percent_change(int v1, int v2);
static std::string get_percent_change_string(int v1, int v2, int precision);
static int get_num_digits(int x);