Skip to content

Commit

Permalink
Merge pull request #26 from heissgetraenk/clean-up
Browse files Browse the repository at this point in the history
code clean up and minor fixes, removed the dependent libraries from the repo
  • Loading branch information
heissgetraenk committed Jan 16, 2023
2 parents 57c7b64 + 115aa1a commit 8998d55
Show file tree
Hide file tree
Showing 183 changed files with 128 additions and 291,591 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ If you have thoughts on how to optimize the recompute performance, please let me

This workbench is very much a work in progress. Any advice is welcome, as are contributions to the code. The following points could be improved upon in the future:

* comments and code clean up (I'll get to it someday, I swear!)
* automate the installation process
* change the number of axis/actuators from the Gui
* accept Node Ids in the form of *ns=2;VariableName*
* implement a switch metric/imperial or read it from the FreeCAD preferences
Expand All @@ -102,3 +100,4 @@ If you find a bug or have a feature you think would be cool to have in this work
* [Assembly4](https://github.com/Zolko-123/FreeCAD_Assembly4) Workbench by [Zolko-123](https://github.com/Zolko-123)
* Tutorial on [FreeCAD Workbenches](https://github.com/felipe-m/tutorial_freecad_wb) by [Felipe Machado](https://github.com/felipe-m)
* Workbench [Starterkit](https://github.com/looooo/Workbench-Starterkit) by [lorenz](https://github.com/looooo)
* Free OPC UA [Library](https://github.com/FreeOpcUa/opcua-asyncio)
52 changes: 20 additions & 32 deletions freecad.fcmcua/freecad/fcmcua/actuator_widgets.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from PySide2 import QtCore, QtWidgets
from PySide2 import QtWidgets

__pos_max__ = 10000
__pos_min__ = -10000
Expand All @@ -13,7 +13,8 @@ class ActuatorWidgets(QtWidgets.QWidget):
def __init__(self, hidden=False):
self.widgets = []

#widget mode
# widget mode: utilize show/hide mechanism only when the Gui widgets are being displayed
# i.e. on the Actuators_Cmd panel
self.hidden = hidden

# type
Expand Down Expand Up @@ -71,17 +72,7 @@ def __init__(self, hidden=False):
self.openSpin.setValue(100)
self.openSpin.setSuffix(__pos_unit__)
self.widgets.append(self.openSpin)
self.openSpin.textChanged[str].connect(self._onOpenPosChanged)

self.blockSLabel = QtWidgets.QLabel('Block postion')
self.widgets.append(self.blockSLabel)

self.blockSpin = QtWidgets.QDoubleSpinBox()
self.blockSpin.setRange(__pos_min__, __pos_max__)
self.blockSpin.setValue(50)
self.blockSpin.setSuffix(__pos_unit__)
self.widgets.append(self.blockSpin)
self.blockSpin.textChanged[str].connect(self._onBlockPosChanged)
self.openSpin.textChanged.connect(self._onNodePosChanged)

self.closeSLabel = QtWidgets.QLabel('Close postion')
self.widgets.append(self.closeSLabel)
Expand All @@ -91,7 +82,16 @@ def __init__(self, hidden=False):
self.closeSpin.setValue(0)
self.closeSpin.setSuffix(__pos_unit__)
self.widgets.append(self.closeSpin)
self.closeSpin.textChanged[str].connect(self._onClosePosChanged)
self.closeSpin.textChanged.connect(self._onNodePosChanged)

self.blockSLabel = QtWidgets.QLabel('Block postion')
self.widgets.append(self.blockSLabel)

self.blockSpin = QtWidgets.QDoubleSpinBox()
self.blockSpin.setRange(__pos_min__, __pos_max__)
self.blockSpin.setValue(50)
self.blockSpin.setSuffix(__pos_unit__)
self.widgets.append(self.blockSpin)

# duration spin boxes (open & close)
self.openTLabel = QtWidgets.QLabel('Opening duration')
Expand All @@ -115,27 +115,13 @@ def __init__(self, hidden=False):
# call _onBlockChecked once
self._onBlockChecked()

def _onClosePosChanged(self, value):
'''
closing position must be < opening position
'''
self.openSpin.setMinimum(float(value[:-3].replace(',', '.' )))
self.blockSpin.setMinimum(float(value[:-3].replace(',', '.' )))

def _onOpenPosChanged(self, value):
'''
closing position must be < opening position
'''
self.closeSpin.setMaximum(float(value[:-3].replace(',', '.' )))
self.blockSpin.setMaximum(float(value[:-3].replace(',', '.' )))


def _onBlockPosChanged(self, value):
def _onNodePosChanged(self):
'''
blocking position must between opening and closing position
'''
self.closeSpin.setMaximum(float(value[:-3].replace(',', '.' )))
self.openSpin.setMinimum(float(value[:-3].replace(',', '.' )))
self.blockSpin.setMinimum(min(self.closeSpin.value(), self.openSpin.value()))
self.blockSpin.setMaximum(max(self.closeSpin.value(), self.openSpin.value()))


def _onTypeChanged(self):
Expand Down Expand Up @@ -163,8 +149,10 @@ def _onTypeChanged(self):


def _onBlockChecked(self):
'''
hide block node id and block position widgets if block option is unchecked
'''
if not self.hidden:
# print("option checkbox is checked:", self.blockCheck.isChecked())
if self.blockCheck.isChecked():
self.blockLabel.show()
self.blockSLabel.show()
Expand Down
5 changes: 1 addition & 4 deletions freecad.fcmcua/freecad/fcmcua/axis_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,11 @@ class AxisWidgets(QtWidgets.QWidget):
def __init__(self, id):
self.id= id
self.widgets=[]

#node LineEdit
self.nodeID = QtWidgets.QLineEdit("ns=2;i=2")
self.widgets.append(self.nodeID)

#opc variable LineEdit
# self.var = QtWidgets.QLineEdit("Variable " + str(self.id))
# self.widgets.append(self.var)

# equals Label
self.equals = QtWidgets.QLabel("=")
self.widgets.append(self.equals)
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 8998d55

Please sign in to comment.