Skip to content
Snippets Groups Projects
Commit b1f0d32c authored by Sebastian Steinlechner's avatar Sebastian Steinlechner
Browse files

added GUI

parent d58b456e
No related branches found
No related tags found
No related merge requests found
Showing with 2001 additions and 0 deletions
+1.000000e+002 -6.135553e-001
+1.017419e+002 -6.238732e-001
+1.035142e+002 -6.348403e-001
+1.053174e+002 -6.456722e-001
+1.071519e+002 -6.567885e-001
+1.090184e+002 -6.682087e-001
+1.109175e+002 -6.794590e-001
+1.128496e+002 -6.912490e-001
+1.148154e+002 -7.035475e-001
+1.168154e+002 -7.153000e-001
+1.188502e+002 -7.280779e-001
+1.209205e+002 -7.402129e-001
+1.230269e+002 -7.532825e-001
+1.251699e+002 -7.660359e-001
+1.273503e+002 -7.794507e-001
+1.295687e+002 -7.930958e-001
+1.318257e+002 -8.068266e-001
+1.341220e+002 -8.206892e-001
+1.364583e+002 -8.349768e-001
+1.388353e+002 -8.495677e-001
+1.412538e+002 -8.641182e-001
+1.437143e+002 -8.787877e-001
+1.462177e+002 -8.941236e-001
+1.487647e+002 -9.097483e-001
+1.513561e+002 -9.257677e-001
+1.539926e+002 -9.414117e-001
+1.566751e+002 -9.578071e-001
+1.594043e+002 -9.745342e-001
+1.621810e+002 -9.914201e-001
+1.650061e+002 -1.008569e+000
+1.678804e+002 -1.025754e+000
+1.708048e+002 -1.044043e+000
+1.737801e+002 -1.061448e+000
+1.768072e+002 -1.080371e+000
+1.798871e+002 -1.099224e+000
+1.830206e+002 -1.118318e+000
+1.862087e+002 -1.137305e+000
+1.894523e+002 -1.157301e+000
+1.927525e+002 -1.177305e+000
+1.961101e+002 -1.197824e+000
+1.995262e+002 -1.218289e+000
+2.030018e+002 -1.239715e+000
+2.065380e+002 -1.261145e+000
+2.101358e+002 -1.282768e+000
+2.137962e+002 -1.305629e+000
+2.175204e+002 -1.327302e+000
+2.213095e+002 -1.351110e+000
+2.251645e+002 -1.374744e+000
+2.290868e+002 -1.398358e+000
+2.330773e+002 -1.423280e+000
+2.371374e+002 -1.447693e+000
+2.412682e+002 -1.472333e+000
+2.454709e+002 -1.498320e+000
+2.497468e+002 -1.524190e+000
+2.540973e+002 -1.551012e+000
+2.585235e+002 -1.577682e+000
+2.630268e+002 -1.605301e+000
+2.676086e+002 -1.633121e+000
+2.722701e+002 -1.661235e+000
+2.770129e+002 -1.689976e+000
+2.818383e+002 -1.719362e+000
+2.867477e+002 -1.749287e+000
+2.917427e+002 -1.779801e+000
+2.968247e+002 -1.810655e+000
+3.019952e+002 -1.842027e+000
+3.072557e+002 -1.875061e+000
+3.126079e+002 -1.907582e+000
+3.180534e+002 -1.940236e+000
+3.235937e+002 -1.973573e+000
+3.292304e+002 -2.009627e+000
+3.349655e+002 -2.043433e+000
+3.408003e+002 -2.079043e+000
+3.467368e+002 -2.115597e+000
+3.527768e+002 -2.151742e+000
+3.589219e+002 -2.188608e+000
+3.651741e+002 -2.227371e+000
+3.715352e+002 -2.266069e+000
+3.780071e+002 -2.306130e+000
+3.845918e+002 -2.346399e+000
+3.912911e+002 -2.386209e+000
+3.981072e+002 -2.427586e+000
+4.050419e+002 -2.471137e+000
+4.120975e+002 -2.513633e+000
+4.192760e+002 -2.557581e+000
+4.265795e+002 -2.601489e+000
+4.340103e+002 -2.647974e+000
+4.415704e+002 -2.693319e+000
+4.492623e+002 -2.739925e+000
+4.570882e+002 -2.787540e+000
+4.650504e+002 -2.835555e+000
+4.731512e+002 -2.884999e+000
+4.813932e+002 -2.936479e+000
+4.897788e+002 -2.986059e+000
+4.983105e+002 -3.038164e+000
+5.069907e+002 -3.092318e+000
+5.158221e+002 -3.145811e+000
+5.248074e+002 -3.200011e+000
+5.339493e+002 -3.256824e+000
+5.432503e+002 -3.312612e+000
+5.527134e+002 -3.370571e+000
+5.623413e+002 -3.429137e+000
+5.721370e+002 -3.489138e+000
+5.821032e+002 -3.549771e+000
+5.922431e+002 -3.611604e+000
+6.025596e+002 -3.675615e+000
+6.130558e+002 -3.738073e+000
+6.237349e+002 -3.804190e+000
+6.345999e+002 -3.869581e+000
+6.456542e+002 -3.937119e+000
+6.569011e+002 -4.005676e+000
+6.683439e+002 -4.074513e+000
+6.799860e+002 -4.145847e+000
+6.918310e+002 -4.217124e+000
+7.038822e+002 -4.292778e+000
+7.161434e+002 -4.364843e+000
+7.286182e+002 -4.442997e+000
+7.413102e+002 -4.518531e+000
+7.542234e+002 -4.599145e+000
+7.673615e+002 -4.676033e+000
+7.807285e+002 -4.759437e+000
+7.943282e+002 -4.841706e+000
+8.081649e+002 -4.926360e+000
+8.222427e+002 -5.012267e+000
+8.365656e+002 -5.100883e+000
+8.511381e+002 -5.189679e+000
+8.659643e+002 -5.278666e+000
+8.810489e+002 -5.371538e+000
+8.963962e+002 -5.465372e+000
+9.120109e+002 -5.560565e+000
+9.278975e+002 -5.656752e+000
+9.440609e+002 -5.755536e+000
+9.605058e+002 -5.856786e+000
+9.772372e+002 -5.959533e+000
+9.942601e+002 -6.061758e+000
+1.011579e+003 -6.167388e+000
+1.029201e+003 -6.274494e+000
+1.047129e+003 -6.384505e+000
+1.065369e+003 -6.495344e+000
+1.083927e+003 -6.608728e+000
+1.102808e+003 -6.721910e+000
+1.122018e+003 -6.840108e+000
+1.141563e+003 -6.959048e+000
+1.161449e+003 -7.077780e+000
+1.181680e+003 -7.204404e+000
+1.202264e+003 -7.330235e+000
+1.223207e+003 -7.457117e+000
+1.244515e+003 -7.585674e+000
+1.266193e+003 -7.721691e+000
+1.288250e+003 -7.852040e+000
+1.310690e+003 -7.988098e+000
+1.333521e+003 -8.127123e+000
+1.356750e+003 -8.271638e+000
+1.380384e+003 -8.415646e+000
+1.404430e+003 -8.560691e+000
+1.428894e+003 -8.711177e+000
+1.453784e+003 -8.861726e+000
+1.479108e+003 -9.019884e+000
+1.504874e+003 -9.177001e+000
+1.531087e+003 -9.334877e+000
+1.557758e+003 -9.497826e+000
+1.584893e+003 -9.661451e+000
+1.612501e+003 -9.833627e+000
+1.640590e+003 -9.995918e+000
+1.669168e+003 -1.017378e+001
+1.698244e+003 -1.035401e+001
+1.727826e+003 -1.053427e+001
+1.757924e+003 -1.071928e+001
+1.788546e+003 -1.090307e+001
+1.819701e+003 -1.109553e+001
+1.851399e+003 -1.128811e+001
+1.883649e+003 -1.148470e+001
+1.916461e+003 -1.168350e+001
+1.949845e+003 -1.189054e+001
+1.983810e+003 -1.209422e+001
+2.018366e+003 -1.231254e+001
+2.053525e+003 -1.251816e+001
+2.089296e+003 -1.273796e+001
+2.125690e+003 -1.296173e+001
+2.162719e+003 -1.318372e+001
+2.200392e+003 -1.341300e+001
+2.238721e+003 -1.364997e+001
+2.277718e+003 -1.388412e+001
+2.317395e+003 -1.412115e+001
+2.357762e+003 -1.437167e+001
+2.398833e+003 -1.462250e+001
+2.440619e+003 -1.488318e+001
+2.483133e+003 -1.514008e+001
+2.526388e+003 -1.540763e+001
+2.570396e+003 -1.567798e+001
+2.615170e+003 -1.594984e+001
+2.660725e+003 -1.622258e+001
+2.707073e+003 -1.649881e+001
+2.754229e+003 -1.679301e+001
+2.802206e+003 -1.708646e+001
+2.851018e+003 -1.738905e+001
+2.900681e+003 -1.769065e+001
+2.951209e+003 -1.799489e+001
+3.002617e+003 -1.830621e+001
+3.054921e+003 -1.862451e+001
+3.108136e+003 -1.894425e+001
+3.162278e+003 -1.928560e+001
+3.217363e+003 -1.962112e+001
+3.273407e+003 -1.995406e+001
+3.330428e+003 -2.030331e+001
+3.388442e+003 -2.066495e+001
+3.447466e+003 -2.102374e+001
+3.507519e+003 -2.139026e+001
+3.568617e+003 -2.176401e+001
+3.630781e+003 -2.214157e+001
+3.694026e+003 -2.252732e+001
+3.758374e+003 -2.292344e+001
+3.823843e+003 -2.331691e+001
+3.890451e+003 -2.372019e+001
+3.958221e+003 -2.414042e+001
+4.027170e+003 -2.456314e+001
+4.097321e+003 -2.498629e+001
+4.168694e+003 -2.542866e+001
+4.241310e+003 -2.586354e+001
+4.315191e+003 -2.631337e+001
+4.390359e+003 -2.676453e+001
+4.466836e+003 -2.724964e+001
+4.544646e+003 -2.771535e+001
+4.623810e+003 -2.820967e+001
+4.704354e+003 -2.869691e+001
+4.786301e+003 -2.919470e+001
+4.869675e+003 -2.970655e+001
+4.954502e+003 -3.022495e+001
+5.040806e+003 -3.075098e+001
+5.128614e+003 -3.128715e+001
+5.217951e+003 -3.182534e+001
+5.308844e+003 -3.237203e+001
+5.401321e+003 -3.294405e+001
+5.495409e+003 -3.352785e+001
+5.591135e+003 -3.410001e+001
+5.688529e+003 -3.470741e+001
+5.787620e+003 -3.529623e+001
+5.888437e+003 -3.590536e+001
+5.991009e+003 -3.654941e+001
+6.095369e+003 -3.716671e+001
+6.201546e+003 -3.782350e+001
+6.309573e+003 -3.848059e+001
+6.419482e+003 -3.916904e+001
+6.531306e+003 -3.984099e+001
+6.645077e+003 -4.052745e+001
+6.760830e+003 -4.125095e+001
+6.878599e+003 -4.196481e+001
+6.998420e+003 -4.269186e+001
+7.120328e+003 -4.344035e+001
+7.244359e+003 -4.419581e+001
+7.370552e+003 -4.497152e+001
+7.498942e+003 -4.574391e+001
+7.629569e+003 -4.653540e+001
+7.762471e+003 -4.735049e+001
+7.897688e+003 -4.819805e+001
+8.035261e+003 -4.901926e+001
+8.175230e+003 -4.986845e+001
+8.317638e+003 -5.073444e+001
+8.462525e+003 -5.162970e+001
+8.609938e+003 -5.250829e+001
+8.759917e+003 -5.344325e+001
+8.912510e+003 -5.436944e+001
+9.067760e+003 -5.534203e+001
+9.225714e+003 -5.630257e+001
+9.386420e+003 -5.725551e+001
+9.549926e+003 -5.827983e+001
+9.716279e+003 -5.927481e+001
+9.885531e+003 -6.030452e+001
+1.005773e+004 -6.137114e+001
+1.023293e+004 -6.242461e+001
+1.041118e+004 -6.351874e+001
+1.059254e+004 -6.463960e+001
+1.077705e+004 -6.576360e+001
+1.096478e+004 -6.689764e+001
+1.115578e+004 -6.805865e+001
+1.135011e+004 -6.926640e+001
+1.154782e+004 -7.049091e+001
+1.174898e+004 -7.168356e+001
+1.195364e+004 -7.294303e+001
+1.216186e+004 -7.420141e+001
+1.237371e+004 -7.551113e+001
+1.258925e+004 -7.681396e+001
+1.280855e+004 -7.818276e+001
+1.303167e+004 -7.950708e+001
+1.325867e+004 -8.089035e+001
+1.348963e+004 -8.232543e+001
+1.372461e+004 -8.374014e+001
+1.396368e+004 -8.519637e+001
+1.420692e+004 -8.672047e+001
+1.445440e+004 -8.819399e+001
+1.470618e+004 -8.976287e+001
+1.496236e+004 -9.132827e+001
+1.522299e+004 -9.289736e+001
+1.548817e+004 -9.453941e+001
+1.575796e+004 -9.617596e+001
+1.603245e+004 -9.785886e+001
+1.631173e+004 -9.955123e+001
+1.659587e+004 -1.012874e+002
+1.688496e+004 -1.031004e+002
+1.717908e+004 -1.048411e+002
+1.747833e+004 -1.067159e+002
+1.778279e+004 -1.085691e+002
+1.809256e+004 -1.104550e+002
+1.840772e+004 -1.123410e+002
+1.872837e+004 -1.143197e+002
+1.905461e+004 -1.163433e+002
+1.938653e+004 -1.183448e+002
+1.972423e+004 -1.204316e+002
+2.006781e+004 -1.224896e+002
+2.041738e+004 -1.246269e+002
+2.077304e+004 -1.268018e+002
+2.113489e+004 -1.290802e+002
+2.150305e+004 -1.312150e+002
+2.187762e+004 -1.335288e+002
+2.225871e+004 -1.359025e+002
+2.264644e+004 -1.382991e+002
+2.304093e+004 -1.407259e+002
+2.344229e+004 -1.431792e+002
+2.385064e+004 -1.456198e+002
+2.426610e+004 -1.481836e+002
+2.468880e+004 -1.507392e+002
+2.511887e+004 -1.533620e+002
+2.555642e+004 -1.560655e+002
+2.600160e+004 -1.587801e+002
+2.645453e+004 -1.615579e+002
+2.691535e+004 -1.643868e+002
+2.738420e+004 -1.671925e+002
+2.786121e+004 -1.701444e+002
+2.834654e+004 -1.731752e+002
+2.884031e+004 -1.762248e+002
+2.934270e+004 -1.792334e+002
+2.985383e+004 +1.776082e+002
+3.037386e+004 +1.743951e+002
+3.090296e+004 +1.711982e+002
+3.144126e+004 +1.678848e+002
+3.198895e+004 +1.644883e+002
+3.254618e+004 +1.611437e+002
+3.311311e+004 +1.577291e+002
+3.368992e+004 +1.541756e+002
+3.427678e+004 +1.505693e+002
+3.487386e+004 +1.468839e+002
+3.548134e+004 +1.432260e+002
+3.609940e+004 +1.393655e+002
+3.672823e+004 +1.355531e+002
+3.736801e+004 +1.316669e+002
+3.801894e+004 +1.275963e+002
+3.868121e+004 +1.235234e+002
+3.935501e+004 +1.194739e+002
+4.004055e+004 +1.153375e+002
+4.073803e+004 +1.110091e+002
+4.144766e+004 +1.066752e+002
+4.216965e+004 +1.021745e+002
+4.290422e+004 +9.773166e+001
+4.365158e+004 +9.312222e+001
+4.441196e+004 +8.840538e+001
+4.518559e+004 +8.386469e+001
+4.597270e+004 +7.899471e+001
+4.677352e+004 +7.416089e+001
+4.758828e+004 +6.938078e+001
+4.841724e+004 +6.442118e+001
+4.926063e+004 +5.879954e+001
+5.011872e+004 +5.633213e+001
+5.099176e+004 +4.841442e+001
+5.188000e+004 +4.268068e+001
+5.278372e+004 +3.754085e+001
+5.370318e+004 +3.171416e+001
+5.463866e+004 +2.607263e+001
+5.559043e+004 +2.013362e+001
+5.655878e+004 +1.436964e+001
+5.754399e+004 +8.361854e+000
+5.854638e+004 +2.291040e+000
+5.956621e+004 -3.937848e+000
+6.060382e+004 -1.027921e+001
+6.165950e+004 -1.666444e+001
+6.273357e+004 -2.322223e+001
+6.382635e+004 -2.991808e+001
+6.493816e+004 -3.673725e+001
+6.606934e+004 -4.353139e+001
+6.722023e+004 -5.064981e+001
+6.839116e+004 -5.768159e+001
+6.958249e+004 -6.489761e+001
+7.079458e+004 -7.248820e+001
+7.202777e+004 -7.984116e+001
+7.328245e+004 -8.746202e+001
+7.455898e+004 -9.522345e+001
+7.585776e+004 -1.031731e+002
+7.717915e+004 -1.110265e+002
+7.852356e+004 -1.193067e+002
+7.989139e+004 -1.277027e+002
+8.128305e+004 -1.360424e+002
+8.269895e+004 -1.446216e+002
+8.413952e+004 -1.533583e+002
+8.560517e+004 -1.621686e+002
+8.709636e+004 -1.711577e+002
+8.861352e+004 +1.796665e+002
+9.015712e+004 +1.702157e+002
+9.172759e+004 +1.604730e+002
+9.332543e+004 +1.513110e+002
+9.495110e+004 +1.412710e+002
+9.660509e+004 +1.310453e+002
+9.828789e+004 +1.211797e+002
+1.000000e+005 +1.575518e+002
File added
import QtQuick 2.4
import QtQuick.LocalStorage 2.0
import QtQuick.Controls 2.2
import "database.js" as DataBase
FilterPaneForm {
property int servoId: 0
signal coeffsChanged(int servoId)
function updateFromDB() {
var filters = DataBase.getFilters()
sos.txtFM1.text = filters[0].name
sos.txtFM2.text = filters[1].name
sos.txtFM3.text = filters[2].name
sos.txtFM4.text = filters[3].name
sos.txtFM5.text = filters[4].name
var rps = [sos.rpFM1, sos.rpFM2, sos.rpFM3, sos.rpFM4, sos.rpFM5];
for (var i=0; i < DataBase.NUM_SOS; i++) {
rps[i].itemAt(0).text = filters[i].gain.toFixed(5)
rps[i].itemAt(1).text = filters[i].C1.toFixed(5)
rps[i].itemAt(2).text = filters[i].C2.toFixed(5)
rps[i].itemAt(3).text = filters[i].C3.toFixed(5)
rps[i].itemAt(4).text = filters[i].C4.toFixed(5)
}
}
function saveToDB() {
var rps = [sos.rpFM1, sos.rpFM2, sos.rpFM3, sos.rpFM4, sos.rpFM5];
var names = [sos.txtFM1.text, sos.txtFM2.text, sos.txtFM3.text, sos.txtFM4.text, sos.txtFM5.text];
for (var i=0; i < DataBase.NUM_SOS; i++) {
DataBase.saveFilter(i+1, names[i],
rps[i].itemAt(0).text,
rps[i].itemAt(1).text,
rps[i].itemAt(2).text,
rps[i].itemAt(3).text,
rps[i].itemAt(4).text);
}
coeffsChanged(servoId)
}
Component.onCompleted: DataBase.initialiseFilterDB()
onServoIdChanged: updateFromDB()
btnSaveCoeffs.onClicked: saveToDB()
}
import QtQuick 2.4
import QtQuick.Controls 2.2
Item {
id: item1
width: 750
height: 600
property alias sos: sos
property alias btnSaveCoeffs: btnSaveCoeffs
property alias servoName: servoName.text
SecondOrderSection {
id: sos
anchors.top: parent.top
anchors.topMargin: 80
anchors.right: parent.right
anchors.rightMargin: 20
anchors.left: parent.left
anchors.leftMargin: 20
}
Label {
id: servoName
text: qsTr("ServoName")
font.bold: true
anchors.top: parent.top
anchors.topMargin: 20
anchors.left: parent.left
anchors.leftMargin: 20
font.pointSize: 16
}
Label {
id: label1
y: 28
text: qsTr("Filter Coefficients")
anchors.bottom: servoName.bottom
anchors.bottomMargin: 0
anchors.left: servoName.right
anchors.leftMargin: 10
font.pointSize: 16
}
Rectangle {
id: rectangle
height: 1
color: "#888888"
anchors.top: servoName.bottom
anchors.topMargin: 10
anchors.right: label1.right
anchors.rightMargin: 0
anchors.left: servoName.left
anchors.leftMargin: 0
border.color: "#00000000"
}
Button {
id: btnSaveCoeffs
text: qsTr("Update Coeffs")
anchors.left: parent.left
anchors.leftMargin: 20
anchors.top: sos.bottom
anchors.topMargin: 20
}
}
import QtQuick 2.4
PaneHeader {
}
import QtQuick 2.4
Item {
width: 400
height: 140
Image {
id: image
x: 0
y: 0
width: 119
height: 101
source: "qt-logo.png"
}
Row {
x: 0
y: 111
spacing: -8
Text {
id: text1
width: 50
text: qsTr("Monitor")
rotation: -45
font.pixelSize: 12
}
Text {
id: text2
width: 50
text: qsTr("Ramp")
rotation: -45
font.pixelSize: 12
}
}
}
import QtQuick 2.7
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
Pane {
width: 650
property alias cbFM1: cbFM1
property alias rpFM1: rpFM1
property alias txtFM1: txtFM1
property alias cbFM2: cbFM2
property alias rpFM2: rpFM2
property alias txtFM2: txtFM2
property alias cbFM3: cbFM3
property alias rpFM3: rpFM3
property alias txtFM3: txtFM3
property alias cbFM4: cbFM4
property alias rpFM4: rpFM4
property alias txtFM4: txtFM4
property alias cbFM5: cbFM5
property alias rpFM5: rpFM5
property alias txtFM5: txtFM5
padding: 0
contentHeight: layout.height
GridLayout {
id: layout
rows: 3
columns: 7
anchors {
left: parent.left
right: parent.right
}
Label {
text: qsTr("Name")
horizontalAlignment: Text.AlignHCenter
Layout.fillHeight: true; Layout.fillWidth: true
}
Label {
text: qsTr("Gain")
horizontalAlignment: Text.AlignHCenter
Layout.fillHeight: true; Layout.fillWidth: true
}
Label {
text: qsTr("C1")
horizontalAlignment: Text.AlignHCenter
Layout.fillHeight: true; Layout.fillWidth: true
}
Label {
text: qsTr("C2")
horizontalAlignment: Text.AlignHCenter
Layout.fillHeight: true; Layout.fillWidth: true
}
Label {
text: qsTr("C3")
horizontalAlignment: Text.AlignHCenter
Layout.fillHeight: true; Layout.fillWidth: true
}
Label {
text: qsTr("C4")
horizontalAlignment: Text.AlignHCenter
Layout.fillHeight: true; Layout.fillWidth: true
}
Label {
text: qsTr("Wizard")
horizontalAlignment: Text.AlignHCenter
Layout.fillHeight: true; Layout.fillWidth: true
}
// SECOND ORDER SECTION 1
TextField {
id: txtFM1
text: qsTr("FM1")
font.pointSize: 14
selectByMouse: true
Layout.fillHeight: true; Layout.fillWidth: true
}
Repeater {
id: rpFM1
model: 5
TextField {
text: qsTr("0.0")
horizontalAlignment: Text.AlignRight
font.pointSize: 14
selectByMouse: true
Layout.fillHeight: true; Layout.fillWidth: true
}
}
ComboBox {
id: cbFM1
model: ["Integrator", "Differentiator", "Lowpass", "Highpass", "Notch"]
font.pointSize: 14
Layout.fillHeight: true; Layout.fillWidth: true
}
// SECOND ORDER SECTION 2
TextField {
id: txtFM2
text: qsTr("FM2")
font.pointSize: 14
selectByMouse: true
Layout.fillHeight: true; Layout.fillWidth: true
}
Repeater {
id: rpFM2
model: 5
TextField {
text: qsTr("0.0")
horizontalAlignment: Text.AlignRight
font.pointSize: 14
selectByMouse: true
Layout.fillHeight: true; Layout.fillWidth: true
}
}
ComboBox {
id: cbFM2
model: ["Integrator", "Differentiator", "Lowpass", "Highpass", "Notch"]
font.pointSize: 14
Layout.fillHeight: true; Layout.fillWidth: true
}
// SECOND ORDER SECTION 3
TextField {
id: txtFM3
text: qsTr("FM3")
font.pointSize: 14
selectByMouse: true
Layout.fillHeight: true; Layout.fillWidth: true
}
Repeater {
id: rpFM3
model: 5
TextField {
text: qsTr("0.0")
horizontalAlignment: Text.AlignRight
font.pointSize: 14
selectByMouse: true
Layout.fillHeight: true; Layout.fillWidth: true
}
}
ComboBox {
id: cbFM3
model: ["Integrator", "Differentiator", "Lowpass", "Highpass", "Notch"]
font.pointSize: 14
Layout.fillHeight: true; Layout.fillWidth: true
}
// SECOND ORDER SECTION 4
TextField {
id: txtFM4
text: qsTr("FM4")
font.pointSize: 14
selectByMouse: true
Layout.fillHeight: true; Layout.fillWidth: true
}
Repeater {
id: rpFM4
model: 5
TextField {
text: qsTr("0.0")
horizontalAlignment: Text.AlignRight
font.pointSize: 14
selectByMouse: true
Layout.fillHeight: true; Layout.fillWidth: true
}
}
ComboBox {
id: cbFM4
model: ["Integrator", "Differentiator", "Lowpass", "Highpass", "Notch"]
font.pointSize: 14
Layout.fillHeight: true; Layout.fillWidth: true
}
// SECOND ORDER SECTION 5
TextField {
id: txtFM5
text: qsTr("FM5")
font.pointSize: 14
selectByMouse: true
Layout.fillHeight: true; Layout.fillWidth: true
}
Repeater {
id: rpFM5
model: 5
TextField {
text: qsTr("0.0")
horizontalAlignment: Text.AlignRight
font.pointSize: 14
selectByMouse: true
Layout.fillHeight: true; Layout.fillWidth: true
}
}
ComboBox {
id: cbFM5
model: ["Integrator", "Differentiator", "Lowpass", "Highpass", "Notch"]
font.pointSize: 14
Layout.fillHeight: true; Layout.fillWidth: true
Layout.minimumWidth: 120
}
}
}
import QtQuick 2.7
import QtQuick.LocalStorage 2.0
import QtQuick.Controls 2.2
import QtQuick.Controls.Material 2.2
import "database.js" as DataBase
Item {
property alias currentItem: listView.currentItem
property alias currentIndex: listView.currentIndex
property int numServos: 8
function loadServos() {
var servos = DataBase.loadServos()
servoModel.clear()
for (var j = 1; j <= numServos; j++) {
servoModel.append({"servoId": j, "servoName": '(Empty Slot)'})
}
for (var i = 0; i < servos.length; i++) {
servoModel.remove(servos[i].id - 1)
servoModel.insert(servos[i].id - 1, {"servoId": servos[i].id, "servoName": servos[i].name})
}
listView.update()
listView.currentIndex = 0
}
ButtonGroup {
id: monitorGroup1
}
ButtonGroup {
id: monitorGroup2
}
ListModel {
id: servoModel
ListElement { servoName: 'Dummy Servo'; servoId: 0 }
}
ListView {
id: listView
anchors.fill: parent
model: servoModel
highlight: Rectangle {
color: Material.color(Material.Indigo, Material.Shade300)
Rectangle {
anchors.bottom: parent.bottom
width: parent.width
height: 1
color: Material.color(Material.Indigo, Material.Shade100)
}
}
highlightMoveDuration: 300
ScrollIndicator.vertical: ScrollIndicator { }
delegate: ItemDelegate {
id: servoItem
width: parent.width
implicitHeight: 50
highlighted: index == listView.currentIndex
onClicked: listView.currentIndex = index
property variant theModel: model
contentItem: Rectangle {
color: 'transparent'
anchors.fill: parent
Row {
RadioButton {
width: 40
ButtonGroup.group: monitorGroup1
}
RadioButton {
width: 40
ButtonGroup.group: monitorGroup2
}
Label {
color: Material.color(Material.Grey, Material.Shade200)
height: parent.height
verticalAlignment: Text.AlignVCenter
text: model.servoName
}
}
}
}
}
Component.onCompleted: loadServos()
}
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
ListView {
id: listView
ScrollIndicator.vertical: ScrollIndicator {
}
}
import QtQuick 2.7
import QtQuick.LocalStorage 2.0
import QtQuick.Controls 2.2
import "database.js" as DataBase
/*
#Define FCR_SW_INPUT 1
#Define FCR_SW_OUTPUT 2
#Define FCR_SW_RAMP 4
#Define FCR_SW_LIMIT 8
#Define FCR_SW_SOS1 16
#Define FCR_SW_SOS2 32
#Define FCR_SW_SOS3 64
#Define FCR_SW_SOS4 128
#Define FCR_SW_SOS5 256
*/
ServoPaneForm {
property int servoId: 1
property int switches: 0
function updateFromDB() {
if (servoId == 0) // this happens on initialisation, just do nothing
return
var myServo = DataBase.getServo()
servoName = myServo.name
offset = myServo.offset.toFixed(1)
gain = myServo.gain.toFixed(2)
switches = myServo.switches
rampAmpl = myServo.ramp_ampl
rampFreq = myServo.ramp_freq
setSwitches()
reloadFilters(false)
focus = true
forceActiveFocus()
// TODO: ultimately, this also needs to get new values from ADwin?
}
function reloadFilters(sendToADwin) {
var filters = DataBase.getFilters()
lblFM1.text = filters[0].name
lblFM2.text = filters[1].name
lblFM3.text = filters[2].name
lblFM4.text = filters[3].name
lblFM5.text = filters[4].name
if (sendToADwin) {
// TODO: this then also needs to send filter values to ADwin
}
}
function setSwitches() {
btnInput.checked = (switches & 1)
btnOutput.checked = (switches & 2)
btnRamp.checked = (switches & 4)
btnFM1.checked = (switches & 16)
btnFM2.checked = (switches & 32)
btnFM3.checked = (switches & 64)
btnFM4.checked = (switches & 128)
btnFM5.checked = (switches & 256)
btnOffset.checked = (switches & 512)
}
function calcSwitchField(bitvalue, checked) {
if (checked)
switches = switches | bitvalue
else
switches = switches & ~bitvalue
saveToDB()
}
function saveToDB()
{
DataBase.saveServo()
}
Component.onCompleted: updateFromDB()
onServoIdChanged: updateFromDB()
Connections {
target: txtServoName
onEditingFinished: saveToDB()
//TODO: not sure why this needs a Connections type, but otherwise I get:
// ".onEditingFinished" is not available due to component versioning.
// maybe this is QTBUG-59908
}
Connections {
target: txtGain
onEditingFinished: saveToDB()
}
Connections {
target: txtOffset
onEditingFinished: saveToDB()
}
btnInput.onClicked: calcSwitchField(1, btnInput.checked)
btnOutput.onClicked: calcSwitchField(2, btnOutput.checked)
btnRamp.onClicked: calcSwitchField(4, btnRamp.checked)
//TODO: limit button missing
btnFM1.onClicked: calcSwitchField(16, btnFM1.checked)
btnFM2.onClicked: calcSwitchField(32, btnFM2.checked)
btnFM3.onClicked: calcSwitchField(64, btnFM3.checked)
btnFM4.onClicked: calcSwitchField(128, btnFM4.checked)
btnFM5.onClicked: calcSwitchField(256, btnFM5.checked)
//TODO: this is not yet implemented in ADwin, I think
btnOffset.onClicked: calcSwitchField(512, btnOffset.checked)
Connections {
target: slRampAmpl
onMoved: saveToDB()
}
Connections {
target: slRampFreq
onMoved: saveToDB()
}
Keys.onPressed: {
if (event.key == Qt.Key_Escape)
focus = true
else if (event.key == Qt.Key_I) {
btnInput.toggle(); btnInput.clicked()
}
else if (event.key == Qt.Key_O) {
btnOutput.toggle(); btnOutput.clicked()
}
else if (event.key == Qt.Key_Plus) {
btnOffset.toggle(); btnOffset.clicked()
}
else if (event.key == Qt.Key_R) {
btnRamp.toggle(); btnRamp.clicked()
}
else if (event.key == Qt.Key_A) {
btnAux.toggle(); btnAux.clicked()
}
}
Keys.onDigit1Pressed: { btnFM1.toggle(); btnFM1.clicked() }
Keys.onDigit2Pressed: { btnFM2.toggle(); btnFM2.clicked() }
Keys.onDigit3Pressed: { btnFM3.toggle(); btnFM3.clicked() }
Keys.onDigit4Pressed: { btnFM4.toggle(); btnFM4.clicked() }
Keys.onDigit5Pressed: { btnFM5.toggle(); btnFM5.clicked() }
}
import QtQuick 2.7
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.0
Item {
id: item1
width: 750
height: 600
property alias lblFM4: lblFM4
property alias lblFM3: lblFM3
property alias lblFM2: lblFM2
property alias lblFM5: lblFM5
property alias lblFM1: lblFM1
property alias btnOutput: btnOutput
property alias btnInput: btnInput
property alias btnOffset: btnOffset
property alias btnFM5: btnFM5
property alias btnFM4: btnFM4
property alias btnFM3: btnFM3
property alias btnFM2: btnFM2
property alias btnFM1: btnFM1
property alias btnAux: btnAux
property alias btnRamp: btnRamp
property alias slRampAmpl: slRampAmpl
property alias slRampFreq: slRampFreq
property alias txtGain: txtGain
property alias txtOffset: txtOffset
property alias txtServoName: txtServoName
property alias offset: txtOffset.text
property alias monOutput: txtMonOutput.text
property alias monAux: txtMonInput.text
property alias gain: txtGain.text
property alias servoName: txtServoName.text
property alias rampFreq: slRampFreq.value
property alias rampAmpl: slRampAmpl.value
TextField {
id: txtServoName
x: 45
y: 139
width: 177
height: 43
font.bold: true
anchors.top: parent.top
anchors.topMargin: 20
anchors.left: parent.left
anchors.leftMargin: 20
selectByMouse: true
}
Rectangle {
id: rectangle
y: 139
height: 2
color: "#000000"
anchors.right: rectangle2.left
anchors.rightMargin: -60
anchors.left: parent.left
anchors.leftMargin: 25
z: -3
}
Rectangle {
id: rectangle1
x: 572
y: 186
width: 74
height: 2
color: "#000000"
z: -3
}
Rectangle {
id: rectangle2
x: 644
y: 141
width: 2
height: 47
color: "#000000"
z: -3
}
Rectangle {
id: rectangle3
x: 640
y: 135
width: 10
height: 10
color: "#000000"
radius: 5
}
RowLayout {
y: 116
width: 730
height: 48
spacing: 5
anchors.left: parent.left
anchors.leftMargin: 20
Column {
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
Button {
id: btnInput
width: 68
text: qsTr("IN")
checkable: true
}
TextField {
id: txtMonInput
width: 68
height: 41
text: qsTr("1000")
enabled: false
horizontalAlignment: Text.AlignRight
font.pointSize: 14
}
}
Column {
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
Button {
id: btnOffset
text: qsTr("Offset")
highlighted: false
checkable: true
}
TextField {
id: txtOffset
width: 68
height: 41
text: qsTr("1000")
horizontalAlignment: Text.AlignRight
font.pointSize: 14
selectByMouse: true
}
}
Button {
id: btnFM1
text: qsTr("FM1")
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
Layout.preferredWidth: 48
checkable: true
highlighted: false
}
Button {
id: btnFM2
text: qsTr("FM2")
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
Layout.preferredWidth: 48
checkable: true
highlighted: false
}
Button {
id: btnFM3
text: qsTr("FM3")
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
Layout.preferredWidth: 48
checkable: true
highlighted: false
}
Button {
id: btnFM4
text: qsTr("FM4")
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
Layout.preferredWidth: 48
checkable: true
highlighted: false
}
Button {
id: btnFM5
text: qsTr("FM5")
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
Layout.preferredWidth: 48
checkable: true
highlighted: false
}
Column {
id: column
Rectangle {
id: rectangle4
width: 78
height: 47
radius: 5
border.width: 2
border.color: "#000000"
Label {
text: 'x'
anchors.verticalCenterOffset: -1
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: 5
font.pointSize: 14
color: '#888888'
}
TextField {
id: txtGain
text: qsTr("1.0")
anchors.margins: 5
anchors.bottomMargin: -3
anchors.fill: parent
horizontalAlignment: Text.AlignRight
font.pointSize: 14
selectByMouse: true
}
}
Button {
id: btnAux
width: 68
text: qsTr("AUX")
anchors.horizontalCenter: parent.horizontalCenter
checkable: true
}
TextField {
id: txtMonAux
width: 68
height: 41
text: qsTr("1000")
enabled: false
anchors.horizontalCenter: parent.horizontalCenter
horizontalAlignment: Text.AlignRight
font.pointSize: 14
}
}
Column {
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
Button {
id: btnOutput
width: 68
text: qsTr("OUT")
checkable: true
}
TextField {
id: txtMonOutput
width: 68
height: 41
text: qsTr("1000")
enabled: false
horizontalAlignment: Text.AlignRight
font.pointSize: 14
}
}
}
Label {
id: lblFM1
x: 226
y: 101
text: qsTr("Notch 2.1kHz")
verticalAlignment: Text.AlignBottom
transformOrigin: Item.TopLeft
rotation: -45
}
Label {
id: lblFM5
x: 508
y: 101
text: qsTr("LP 10kHz")
rotation: -45
verticalAlignment: Text.AlignBottom
transformOrigin: Item.TopLeft
}
Label {
id: lblFM2
x: 298
y: 101
text: qsTr("Notch 3kHz")
rotation: -45
verticalAlignment: Text.AlignBottom
transformOrigin: Item.TopLeft
}
Label {
id: lblFM3
x: 364
y: 101
text: qsTr("Int 100Hz")
rotation: -45
verticalAlignment: Text.AlignBottom
transformOrigin: Item.TopLeft
}
Label {
id: lblFM4
x: 436
y: 101
text: qsTr("Int 1kHz")
rotation: -45
verticalAlignment: Text.AlignBottom
transformOrigin: Item.TopLeft
}
GroupBox {
id: groupBox
x: 8
y: 295
font.italic: false
font.bold: false
title: qsTr("Ramp Generator")
background: Rectangle {
color: 'transparent'
}
RowLayout {
spacing: 10
Button {
id: btnRamp
width: 68
text: qsTr("ON")
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
checkable: true
}
Column {
Slider {
id: slRampFreq
stepSize: 1
to: 255
value: 127
Label {
id: label
x: 0
y: 0
text: qsTr("Frequency")
}
}
Slider {
id: slRampAmpl
value: 0.5
Label {
id: label1
x: 0
y: 0
text: qsTr("Amplitude")
}
}
}
}
}
Text {
id: text1
y: 548
text: qsTr("Servo ID:")
anchors.left: parent.left
anchors.leftMargin: 20
anchors.bottom: parent.bottom
anchors.bottomMargin: 20
font.pixelSize: 12
}
Text {
id: txtServoId
y: 565
text: servoId
anchors.bottom: parent.bottom
anchors.bottomMargin: 20
anchors.left: text1.right
anchors.leftMargin: 6
font.pixelSize: 12
}
}
var db = LocalStorage.openDatabaseSync("ServoController", "", "ServoDataBase", 1000000);
var NUM_SOS = 5;
function getServo() {
console.log("Get Servo..."+servoId);
var servo = Object({'name': '(Empty Slot)',
'gain': 1.0,
'offset': 0.0,
'switches': 0,
'ramp_freq': 10.0,
'ramp_ampl': 1.0
});
db.transaction(
function(tx) {
var result = tx.executeSql('SELECT * FROM Servos WHERE id=?', servoId);
if (result.rows.length == 1)
servo = result.rows.item(0);
console.log(servo.name);
}
)
return servo;
}
function saveServo() {
console.log("Saving Servo..."+servoId);
db.transaction(
function(tx) {
tx.executeSql('INSERT OR REPLACE INTO Servos(id, name, switches, offset, gain, ramp_freq, ramp_ampl) \
VALUES(?, ?, ?, ?, ?, ?, ?)',
[servoId, servoName, switches, offset,
gain, rampFreq, rampAmpl])
}
)
}
function loadServos() {
var servos = [];
var result;
db.transaction(
function(tx) {
tx.executeSql("CREATE TABLE IF NOT EXISTS Servos( \
id INT PRIMARY KEY, \
name TEXT, \
switches INT, \
offset REAL, \
gain REAL, \
ramp_freq REAL, \
ramp_ampl REAL)");
result = tx.executeSql("SELECT id, name FROM Servos ORDER BY id ASC");
for (var i = 0; i < result.rows.length; i++)
servos.push(result.rows.item(i));
}
)
return servos;
}
function initialiseFilterDB() {
console.log('Filter init')
db.transaction(
function(tx) {
tx.executeSql("CREATE TABLE IF NOT EXISTS Filters( \
slot INT, \
servo_id INT, \
name TEXT, \
gain REAL, \
C1 REAL, \
C2 REAL, \
C3 REAL, \
C4 REAL, \
CONSTRAINT fm_unique UNIQUE(servo_id, slot))");
}
)
}
function getFilters() {
console.log("Getting Filters for Servo..."+servoId);
var filter_template = Object({'name': '(empty slot)',
'servo_id': servoId,
'slot': 0,
'gain': 1.0,
'C1': 0.0, 'C2': 0.0, 'C3': 0.0, 'C4': 0.0
});
var filters = [];
for (var i = 1; i <= NUM_SOS; i++) {
var flt = Object.create(filter_template)
flt.slot = i
flt.name = '(empty slot %1)'.arg(i)
filters.push(flt)
}
db.transaction(
function(tx) {
var result = tx.executeSql('SELECT * FROM Filters WHERE servo_id=? ORDER BY slot ASC', servoId);
console.log(result.rows.length)
for (var i = 0; i < result.rows.length; i++) {
filters[result.rows.item(i).slot-1] = result.rows.item(i);
}
}
)
return filters;
}
function saveFilter(slot, name, gain, C1, C2, C3, C4) {
console.log("Saving filter %1, servo %2...".arg(slot).arg(servoId));
db.transaction(
function(tx) {
var result = tx.executeSql('INSERT OR REPLACE INTO Filters \
(name, servo_id, slot, gain, C1, C2, C3, C4) \
VALUES \
(?, ?, ?, ?, ?, ?, ?, ?)',
[name, servoId, slot, gain, C1, C2, C3, C4]);
}
)
}
QT += qml quick
CONFIG += c++11
SOURCES += main.cpp
RESOURCES += qml.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
# Additional import path used to resolve QML modules just for Qt Quick Designer
QML_DESIGNER_IMPORT_PATH =
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
This diff is collapsed.
#include <QGuiApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QLatin1String("qrc:/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;
return app.exec();
}
import QtQuick 2.7
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import QtQuick.Controls.Material 2.2
ApplicationWindow {
id: window
visible: true
width: 1000
height: 600
title: qsTr("Servo Controller")
minimumWidth: 1000
Material.theme: Material.Light
Material.accent: Material.Red
Drawer {
id: drawer
width: 250
height: window.height
y: 0; z: 2
Material.elevation: 5
modal: false
visible: true
position: 1
interactive: false
Pane {
anchors.fill: parent
Material.background: Material.Indigo
ServoList {
id: servoList
numServos: 8
anchors.fill: parent
}
}
}
SwipeView {
id: swipe
currentIndex: page_indicator.currentIndex
anchors.leftMargin: drawer.width
anchors.fill: parent
ServoPane {
id: servoPane
servoId: servoList.currentItem.theModel.servoId
onServoNameChanged: servoList.currentItem.theModel.servoName = servoName
}
FilterPane {
id: filterPane
servoName: servoList.currentItem.theModel.servoName
servoId: servoList.currentItem.theModel.servoId
onCoeffsChanged: servoPane.reloadFilters(true)
}
}
PageIndicator {
id: page_indicator
count: swipe.count
currentIndex: swipe.currentIndex
interactive: true
anchors.bottom: swipe.bottom
anchors.horizontalCenter: swipe.horizontalCenter
}
}
<RCC>
<qresource prefix="/">
<file>main.qml</file>
<file>qtquickcontrols2.conf</file>
<file>qt-logo.png</file>
<file>PaneHeader.ui.qml</file>
<file>ServoList.qml</file>
<file>ServoPaneForm.ui.qml</file>
<file>ServoPane.qml</file>
<file>FilterPane.qml</file>
<file>FilterPaneForm.ui.qml</file>
<file>SecondOrderSection.qml</file>
<file>database.js</file>
</qresource>
</RCC>
first/qt-logo.png

8.97 KiB

[Controls]
Style=Material
[Material]
Theme=Light
[Universal]
Theme=Light
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment