summaryrefslogtreecommitdiff
path: root/wire.cpp
diff options
context:
space:
mode:
authorJoshua Drake <joshua.ellis.drake@gmail.com>2022-11-19 04:04:00 -0600
committerJoshua Drake <joshua.ellis.drake@gmail.com>2022-11-19 04:04:00 -0600
commit1321168cb22a76df96d747194fcb91863e4e0659 (patch)
tree772cc08ae6c85bd1a8b527509c3dd88bcc5600dc /wire.cpp
parent1ed60cd00cd9fdcc45dab1f81e00dd723858a430 (diff)
Added Wire Class. Program now has some functionality!
Diffstat (limited to 'wire.cpp')
-rw-r--r--wire.cpp83
1 files changed, 83 insertions, 0 deletions
diff --git a/wire.cpp b/wire.cpp
new file mode 100644
index 0000000..bc7a7c1
--- /dev/null
+++ b/wire.cpp
@@ -0,0 +1,83 @@
+#include "wire.h"
+#include "QDebug"
+Wire::Wire() :
+ activeWireData(copper[0]),
+ activeWire(wireMaterials[Copper]),
+ systemVoltage(0.0),
+ peakPower(0.0),
+ wireLength(0.0)
+{
+
+}
+
+void Wire::setActiveWireType(int wire)
+{
+ activeWire = wireMaterials[wire];
+}
+
+void Wire::setWireLength(float length)
+{
+ wireLength = length;
+}
+void Wire::setSystemVoltage(double voltage)
+{
+ systemVoltage = voltage;
+}
+
+void Wire::setPeakSystemPower(double power)
+{
+ peakPower = power;
+}
+
+void Wire::calculate()
+{
+ float current = peakPower/systemVoltage;
+ int count = 0;
+ switch (std::distance(wireMaterials, std::find(wireMaterials,wireMaterials+sizeof(wireMaterials),activeWire)))
+ {
+ case Copper:
+{
+ while(current < copper[count].maxCurrent)
+ {
+ activeWireData = copper[count];
+ count++;
+ }
+ break;
+}
+ case Aluminum:
+{
+ break;
+}
+ case Silver:
+{
+ break;
+}
+ case Gold:
+{
+ break;
+}
+ case Tin:
+{
+ break;
+}
+ }
+ qDebug() << activeWireData.AWG;
+ emit calculation();
+}
+
+QString Wire::gauge()
+{
+ return activeWireData.AWG;
+}
+
+double Wire::weight()
+{
+ return (wireLength * activeWireData.weight)/1000.0;
+}
+
+double Wire::peakCurrent()
+{
+ return peakPower/systemVoltage;
+}
+
+