Skip to content

Commit

Permalink
#6 OpenRocket import
Browse files Browse the repository at this point in the history
  • Loading branch information
davesrocketshop committed Jan 1, 2023
1 parent 389ee7a commit 0e33a36
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
4 changes: 2 additions & 2 deletions App/Importer/ComponentElement.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ def onPositionType(self, value):

def onAxialOffset(self, content):
if hasattr(self._feature._obj, "Location"):
self._feature._obj.Location = content
self._feature._obj.Location = -content
if hasattr(self._feature._obj, "AxialOffset"):
self._feature._obj.AxialOffset = content
self._feature._obj.AxialOffset = -content

def onOverrideMass(self, content):
if hasattr(self._feature, "setOverrideMass"):
Expand Down
2 changes: 1 addition & 1 deletion App/position/AxialMethod.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def getAsPosition(self, offset, innerLength, outerLength):
# print("\toffset %g, innerLength %g, outerLength %g" % (offset, innerLength, outerLength))
# print("\tposition %g" % ((float(outerLength) - float(innerLength)) - float(offset)))
# return float(offset) + (float(outerLength) - float(innerLength))
return (float(outerLength) - float(innerLength)) - float(offset)
return (float(outerLength) - float(innerLength)) + float(offset)

ABSOLUTE = AbsoluteAxialMethod()
AFTER = AfterAxialMethod()
Expand Down
36 changes: 36 additions & 0 deletions Tests/Components/PositionTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,54 @@ def testAxialMethod(self):
self.assertEquals(lug.getAxialOffset(), 0.0, lug.getName() + " incorrect axial-position-offset: ")
self.assertEquals(lug.getPosition().x, 0.0, lug.getName() + " incorrect axial-position-value: ")

lug._setAxialOffset(AxialMethod.BOTTOM, -5.0)
# lug.setAxialMethod(AxialMethod.BOTTOM)
self.assertEquals(lug.getAxialMethod(), AxialMethod.BOTTOM, lug.getName() + " incorrect axial-position-method: ")
self.assertEquals(lug.getAxialOffset(), -5.0, lug.getName() + " incorrect axial-position-offset: ")
self.assertEquals(lug.getPosition().x, -5.0, lug.getName() + " incorrect axial-position-value: ")

lug._setAxialOffset(AxialMethod.BOTTOM, 5.0)
# lug.setAxialMethod(AxialMethod.BOTTOM)
self.assertEquals(lug.getAxialMethod(), AxialMethod.BOTTOM, lug.getName() + " incorrect axial-position-method: ")
self.assertEquals(lug.getAxialOffset(), 5.0, lug.getName() + " incorrect axial-position-offset: ")
self.assertEquals(lug.getPosition().x, 5.0, lug.getName() + " incorrect axial-position-value: ")

lug._setAxialOffset(AxialMethod.MIDDLE, 0.0)
# lug.setAxialMethod(AxialMethod.MIDDLE)
self.assertEquals(lug.getAxialMethod(), AxialMethod.MIDDLE, lug.getName() + " incorrect axial-position-method: ")
self.assertEquals(lug.getAxialOffset(), 0.0, lug.getName() + " incorrect axial-position-offset: ")
self.assertEquals(lug.getPosition().x, 75.0, lug.getName() + " incorrect axial-position-value: ")

lug._setAxialOffset(AxialMethod.MIDDLE, -5.0)
# lug.setAxialMethod(AxialMethod.MIDDLE)
self.assertEquals(lug.getAxialMethod(), AxialMethod.MIDDLE, lug.getName() + " incorrect axial-position-method: ")
self.assertEquals(lug.getAxialOffset(), -5.0, lug.getName() + " incorrect axial-position-offset: ")
self.assertEquals(lug.getPosition().x, 70.0, lug.getName() + " incorrect axial-position-value: ")

lug._setAxialOffset(AxialMethod.MIDDLE, 5.0)
# lug.setAxialMethod(AxialMethod.MIDDLE)
self.assertEquals(lug.getAxialMethod(), AxialMethod.MIDDLE, lug.getName() + " incorrect axial-position-method: ")
self.assertEquals(lug.getAxialOffset(), 5.0, lug.getName() + " incorrect axial-position-offset: ")
self.assertEquals(lug.getPosition().x, 80.0, lug.getName() + " incorrect axial-position-value: ")

lug._setAxialOffset(AxialMethod.TOP, 0.0)
# lug.setAxialMethod(AxialMethod.TOP)
self.assertEquals(lug.getAxialMethod(), AxialMethod.TOP, lug.getName() + " incorrect axial-position-method: ")
self.assertEquals(lug.getAxialOffset(), 0.0, lug.getName() + " incorrect axial-position-offset: ")
self.assertEquals(lug.getPosition().x, 150.0, lug.getName() + " incorrect axial-position-value: ")

lug._setAxialOffset(AxialMethod.TOP, -5.0)
# lug.setAxialMethod(AxialMethod.TOP)
self.assertEquals(lug.getAxialMethod(), AxialMethod.TOP, lug.getName() + " incorrect axial-position-method: ")
self.assertEquals(lug.getAxialOffset(), -5.0, lug.getName() + " incorrect axial-position-offset: ")
self.assertEquals(lug.getPosition().x, 145.0, lug.getName() + " incorrect axial-position-value: ")

lug._setAxialOffset(AxialMethod.TOP, 5.0)
# lug.setAxialMethod(AxialMethod.TOP)
self.assertEquals(lug.getAxialMethod(), AxialMethod.TOP, lug.getName() + " incorrect axial-position-method: ")
self.assertEquals(lug.getAxialOffset(), 5.0, lug.getName() + " incorrect axial-position-offset: ")
self.assertEquals(lug.getPosition().x, 155.0, lug.getName() + " incorrect axial-position-value: ")

def testChangeAxialMethod(self):
rocket = TestRockets.makeEstesAlphaIII()
stage = rocket.getChild(0).Proxy
Expand Down

0 comments on commit 0e33a36

Please sign in to comment.