summaryrefslogtreecommitdiff
path: root/wire.cpp
diff options
context:
space:
mode:
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;
+}
+
+