From 1321168cb22a76df96d747194fcb91863e4e0659 Mon Sep 17 00:00:00 2001 From: Joshua Drake Date: Sat, 19 Nov 2022 04:04:00 -0600 Subject: Added Wire Class. Program now has some functionality! --- wire.cpp | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 wire.cpp (limited to 'wire.cpp') 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; +} + + -- cgit v1.2.3