diff --git a/.vscode/browse.vc.db b/.vscode/browse.vc.db new file mode 100644 index 0000000..127329e Binary files /dev/null and b/.vscode/browse.vc.db differ diff --git a/.vscode/browse.vc.db-shm b/.vscode/browse.vc.db-shm new file mode 100644 index 0000000..90a584a Binary files /dev/null and b/.vscode/browse.vc.db-shm differ diff --git a/.vscode/browse.vc.db-wal b/.vscode/browse.vc.db-wal new file mode 100644 index 0000000..5d4c442 Binary files /dev/null and b/.vscode/browse.vc.db-wal differ diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..a1e6f01 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,34 @@ +{ + "env": { + "myDefaultIncludePath": [ + "${workspaceFolder}/StarshipAscension/include" + ], + "myCompilerPath": "/usr/bin/gcc" + }, + "configurations": [ + { + "name": "linux-gcc-x64", + "intelliSenseMode": "linux-gcc-x64", + "includePath": [ + "${workspaceFolder}/**" + ], + "defines": [], + "compilerPath": "/usr/bin/gcc", + "cStandard": "${default}", + "cppStandard": "${default}", + "compileCommands": "build/compile_commands.json", + "browse": { + "path": [ + "${workspaceFolder}/**", + "/usr/local/include", + "/usr/include/x86_64-linux-gnu", + "/usr/include" + ], + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "${workspaceFolder}/.vscode/browse.vc.db" + }, + "configurationProvider": "ms-vscode.cmake-tools" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..2de1bb5 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,24 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "C/C++ Runner: Debug Session", + "type": "cppdbg", + "request": "launch", + "args": [], + "stopAtEntry": false, + "externalConsole": false, + "cwd": "/home/gbowne1/Documents/BendCalc", + "program": "/home/gbowne1/Documents/BendCalc/build/Debug/outDebug", + "MIMode": "gdb", + "miDebuggerPath": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ] + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..3e5eb95 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,59 @@ +{ + "C_Cpp_Runner.cCompilerPath": "gcc", + "C_Cpp_Runner.cppCompilerPath": "g++", + "C_Cpp_Runner.debuggerPath": "gdb", + "C_Cpp_Runner.cStandard": "", + "C_Cpp_Runner.cppStandard": "", + "C_Cpp_Runner.msvcBatchPath": "", + "C_Cpp_Runner.useMsvc": false, + "C_Cpp_Runner.warnings": [ + "-Wall", + "-Wextra", + "-Wpedantic", + "-Wshadow", + "-Wformat=2", + "-Wcast-align", + "-Wconversion", + "-Wsign-conversion", + "-Wnull-dereference" + ], + "C_Cpp_Runner.msvcWarnings": [ + "/W4", + "/permissive-", + "/w14242", + "/w14287", + "/w14296", + "/w14311", + "/w14826", + "/w44062", + "/w44242", + "/w14905", + "/w14906", + "/w14263", + "/w44265", + "/w14928" + ], + "C_Cpp_Runner.enableWarnings": true, + "C_Cpp_Runner.warningsAsError": false, + "C_Cpp_Runner.compilerArgs": [], + "C_Cpp_Runner.linkerArgs": [], + "C_Cpp_Runner.includePaths": [], + "C_Cpp_Runner.includeSearch": [ + "*", + "**/*" + ], + "C_Cpp_Runner.excludeSearch": [ + "**/build", + "**/build/**", + "**/.*", + "**/.*/**", + "**/.vscode", + "**/.vscode/**" + ], + "C_Cpp_Runner.useAddressSanitizer": false, + "C_Cpp_Runner.useUndefinedSanitizer": false, + "C_Cpp_Runner.useLeakSanitizer": false, + "C_Cpp_Runner.showCompilationTime": false, + "C_Cpp_Runner.useLinkTimeOptimization": false, + "C_Cpp_Runner.msvcSecureNoWarnings": false +} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..0c02831 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.13.4) +project(BendCalc) + +# Set C++ standard +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +# Include directories +include_directories(include) + +# Source files +set(SOURCES + src/main.cpp + # Add other source files here +) + +# Create executable +add_executable(bend_calc ${SOURCES}) + +# Add subdirectories for modules +add_subdirectory(tests) +add_subdirectory(docs) \ No newline at end of file diff --git a/docs/Tonnage.md b/docs/Tonnage.md new file mode 100644 index 0000000..62309e0 --- /dev/null +++ b/docs/Tonnage.md @@ -0,0 +1,12 @@ +// Inputs for Bend Angle Tonnage required +// Material Type:L A +// Tensile Strength (if known) in Mpa +// Material Thickness +// K-Factor +// V die opening (print suggested v opening of 8x material thickness) +// Radius +// Minimum Flange +// {[(575 × Material thickness squared) / Die width] / 12} × Material factor + +// Outputs for Bend Angle Tonnage +// P in kN/mt and convert to Tons (lb^2/i) \ No newline at end of file diff --git a/include/DataLoad.h b/include/DataLoad.h new file mode 100644 index 0000000..e69de29 diff --git a/include/DataSave.h b/include/DataSave.h new file mode 100644 index 0000000..e69de29 diff --git a/include/Deserializer.h b/include/Deserializer.h new file mode 100644 index 0000000..b0aeb00 --- /dev/null +++ b/include/Deserializer.h @@ -0,0 +1,12 @@ +#ifndef DESERIALIZER_H +#define DESERIALIZER_H + +#include +#include + +class Deserializer { +public: + static bool deserializeData(const std::string& filename, std::string& data); +}; + +#endif \ No newline at end of file diff --git a/include/Kfactor.h b/include/Kfactor.h new file mode 100644 index 0000000..19b110f --- /dev/null +++ b/include/Kfactor.h @@ -0,0 +1,7 @@ +#ifndef KFACTOR_H +#define KFACTOR_H + +// Function declaration for calculating the K-factor +double calculateKFactor(double neutralAxisLocation, double materialThickness); + +#endif \ No newline at end of file diff --git a/include/Serializer.h b/include/Serializer.h new file mode 100644 index 0000000..14b4049 --- /dev/null +++ b/include/Serializer.h @@ -0,0 +1,12 @@ +#ifndef SERIALIZER_H +#define SERIALIZER_H + +#include +#include + +class Serializer { +public: + static bool serializeData(const std::string& filename, const std::string& data); +}; + +#endif \ No newline at end of file diff --git a/include/Setback.h b/include/Setback.h new file mode 100644 index 0000000..e69de29 diff --git a/include/Tonnage.h b/include/Tonnage.h new file mode 100644 index 0000000..63f8b9d --- /dev/null +++ b/include/Tonnage.h @@ -0,0 +1,7 @@ +#ifndef TONNAGE_H +#define TONNAGE_H + +// Function declaration for calculating the press brake tonnage +double calculateTonnage(double materialThickness, double bendLength, double dieOpeningWidth, double materialFactor, double methodFactor, double multipleBendToolingFactor); + +#endif diff --git a/src/DataLoad.cpp b/src/DataLoad.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/DataSave.cpp b/src/DataSave.cpp new file mode 100644 index 0000000..02358d2 --- /dev/null +++ b/src/DataSave.cpp @@ -0,0 +1 @@ +D \ No newline at end of file diff --git a/src/Deserializer.cpp b/src/Deserializer.cpp new file mode 100644 index 0000000..c4f15d2 --- /dev/null +++ b/src/Deserializer.cpp @@ -0,0 +1,16 @@ +#include "Deserializer.h" + +bool Deserializer::deserializeData(const std::string& filename, std::string& data) { + std::ifstream file(filename, std::ios::binary); + if (file.is_open()) { + file.seekg(0, std::ios::end); + std::streampos fileSize = file.tellg(); + file.seekg(0, std::ios::beg); + + data.resize(fileSize); + file.read(&data[0], fileSize); + file.close(); + return true; + } + return false; +} diff --git a/src/Kfactor.cpp b/src/Kfactor.cpp new file mode 100644 index 0000000..4b1f534 --- /dev/null +++ b/src/Kfactor.cpp @@ -0,0 +1,7 @@ +#include "Kfactor.h" + +// Function definition for calculating the K-factor +double calculateKFactor(double neutralAxisLocation, double materialThickness) { + double kFactor = neutralAxisLocation / materialThickness; + return kFactor; +} \ No newline at end of file diff --git a/src/Serializer.cpp b/src/Serializer.cpp new file mode 100644 index 0000000..c6773ac --- /dev/null +++ b/src/Serializer.cpp @@ -0,0 +1,11 @@ +#include "Serializer.h" + +bool Serializer::serializeData(const std::string& filename, const std::string& data) { + std::ofstream file(filename, std::ios::binary); + if (file.is_open()) { + file.write(data.c_str(), data.size()); + file.close(); + return true; + } + return false; +} \ No newline at end of file diff --git a/src/Setback.cpp b/src/Setback.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/Tonnage.cpp b/src/Tonnage.cpp new file mode 100644 index 0000000..de7a68f --- /dev/null +++ b/src/Tonnage.cpp @@ -0,0 +1,8 @@ +#include "Tonnage.h" +#include + +// Function definition for calculating the press brake tonnage +double calculateTonnage(double materialThickness, double bendLength, double dieOpeningWidth, double materialFactor, double methodFactor, double multipleBendToolingFactor) { + double formingTonnage = (575 * pow(materialThickness, 2) / (dieOpeningWidth / 12)) * bendLength * materialFactor * methodFactor * multipleBendToolingFactor; + return formingTonnage; +} \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..aa6d256 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,97 @@ +/* + * This file is part of . + * + * is free software: you can redistribute it and/or modify + * it under the terms of the as published by + * the , either version of the License, or + * (at your option) any later version. + * + * is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * for more details. + * + * You should have received a copy of the + * along with . If not, see . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "Tonnage.h" +#include "Kfactor.h" + +int main() +{ + + /* + * Required Press Tonnage Calculation + */ + + double materialThickness, bendLength, dieOpeningWidth, materialFactor, methodFactor, multipleBendToolingFactor; + + // Get user inputs + std::cout << "Enter material thickness (in inches): "; + std::cin >> materialThickness; + std::cout << "Enter bend length (in inches): "; + std::cin >> bendLength; + std::cout << "Enter die opening width (in inches): "; + std::cin >> dieOpeningWidth; + std::cout << "Enter material factor: "; + std::cin >> materialFactor; + std::cout << "Enter method factor: "; + std::cin >> methodFactor; + std::cout << "Enter multiple-bend tooling factor: "; + std::cin >> multipleBendToolingFactor; + + // Calculate the press brake tonnage using the module function + double tonnage = calculateTonnage(materialThickness, bendLength, dieOpeningWidth, materialFactor, methodFactor, multipleBendToolingFactor); + + // Output the calculated tonnage + std::cout << "The required press brake tonnage is: " << tonnage << " tons" << std::endl; + + return 0; + + /* + * Kfactor calculation + */ + + // User inputs for K-factor calculation + double neutralAxisLocation, materialThickness; + + // Get user inputs + std::cout << "Enter neutral axis location: "; + std::cin >> neutralAxisLocation; + std::cout << "Enter material thickness: "; + std::cin >> materialThickness; + + // Calculate the K-factor using the module function + double kFactor = calculateKFactor(neutralAxisLocation, materialThickness); + + // Output the calculated K-factor + std::cout << "The calculated K-factor is: " << kFactor << std::endl; + + return 0; +} \ No newline at end of file