aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsam-anthony <samanthony6@protonmail.com>2022-03-26 14:11:15 -0230
committersam-anthony <samanthony6@protonmail.com>2022-03-26 14:11:15 -0230
commit16235e23bda445f0bd0b664c3738c77e786a1cbf (patch)
treef29c46905f3afe65cf15a425f270165282620095
parente8c878f4236c056b1c0c9308e2d49c5b23833963 (diff)
downloadvolute-16235e23bda445f0bd0b664c3738c77e786a1cbf.zip
more datapoints and parameters
-rw-r--r--main.go46
-rw-r--r--pressure.go4
-rw-r--r--ui.go59
3 files changed, 87 insertions, 22 deletions
diff --git a/main.go b/main.go
index 08577a1..aca48bb 100644
--- a/main.go
+++ b/main.go
@@ -6,6 +6,9 @@ import (
"os"
)
+// numPoints is the number of datapoints on the compressor map.
+const numPoints = 6
+
func check(err error) {
if err != nil {
fmt.Println(err)
@@ -13,15 +16,26 @@ func check(err error) {
}
}
+var engineSpeed = [numPoints]int32{2000, 3000, 4000, 5000, 6000, 7000}
+
+var volumetricEfficiency = [numPoints]int32{100, 100, 100, 100, 100, 100}
+
var (
- manifoldPressure pressure
+ manifoldPressure [numPoints]pressure
// selectedPressureUnit is used to index pressureUnits
selectedPressureUnit int32
)
func init() {
- manifoldPressure = pressure{100, defaultPressureUnit}
+ manifoldPressure = [numPoints]pressure{
+ newPressure(),
+ newPressure(),
+ newPressure(),
+ newPressure(),
+ newPressure(),
+ newPressure(),
+ }
// selectedPressureUnit is used to index pressureUnitStrings
selectedPressureUnit = defaultPressureUnitIndex
@@ -31,31 +45,19 @@ func loop() {
g.SingleWindow().Layout(
g.Table().
Rows(
- g.TableRow(
- g.Label("Manifold Absolute Pressure"),
- g.Combo(
- "",
- pressureUnitStrings()[selectedPressureUnit],
- pressureUnitStrings(),
- &selectedPressureUnit,
- ).
- OnChange(func() {
- s := pressureUnitStrings()[selectedPressureUnit]
- u, err := pressureUnitFromString(s)
- check(err)
-
- manifoldPressure = pressure{
- manifoldPressure.asUnit(u),
- u,
- }
- }),
- g.InputFloat(&manifoldPressure.val).Format("%.2f"),
- ),
+ engineSpeedRow(),
+ volumetricEfficiencyRow(),
+ manifoldPressureRow(),
).
Columns(
g.TableColumn("Parameter"),
g.TableColumn("Unit"),
g.TableColumn("Point 1"),
+ g.TableColumn("Point 2"),
+ g.TableColumn("Point 3"),
+ g.TableColumn("Point 4"),
+ g.TableColumn("Point 5"),
+ g.TableColumn("Point 6"),
),
)
}
diff --git a/pressure.go b/pressure.go
index f486552..74f035d 100644
--- a/pressure.go
+++ b/pressure.go
@@ -48,6 +48,10 @@ type pressure struct {
unit pressureUnit
}
+func newPressure() pressure {
+ return pressure{100, defaultPressureUnit}
+}
+
func (p pressure) asUnit(u pressureUnit) float32 {
pa := p.val * float32(p.unit) // Convert to pascals.
return pa / float32(u) // Convert to desired unit.
diff --git a/ui.go b/ui.go
new file mode 100644
index 0000000..67f31ca
--- /dev/null
+++ b/ui.go
@@ -0,0 +1,59 @@
+package main
+
+import g "github.com/AllenDang/giu"
+
+func engineSpeedRow() *g.TableRowWidget {
+ return g.TableRow(
+ g.Label("Engine Speed"),
+ g.Label("rpm"),
+ g.InputInt(&engineSpeed[0]),
+ g.InputInt(&engineSpeed[1]),
+ g.InputInt(&engineSpeed[2]),
+ g.InputInt(&engineSpeed[3]),
+ g.InputInt(&engineSpeed[4]),
+ g.InputInt(&engineSpeed[5]),
+ )
+}
+
+func volumetricEfficiencyRow() *g.TableRowWidget {
+ return g.TableRow(
+ g.Label("Volumetric Efficiency"),
+ g.Label("%"),
+ g.InputInt(&volumetricEfficiency[0]),
+ g.InputInt(&volumetricEfficiency[1]),
+ g.InputInt(&volumetricEfficiency[2]),
+ g.InputInt(&volumetricEfficiency[3]),
+ g.InputInt(&volumetricEfficiency[4]),
+ g.InputInt(&volumetricEfficiency[5]),
+ )
+}
+
+func manifoldPressureRow() *g.TableRowWidget {
+ return g.TableRow(
+ g.Label("Manifold Absolute Pressure"),
+ g.Combo(
+ "",
+ pressureUnitStrings()[selectedPressureUnit],
+ pressureUnitStrings(),
+ &selectedPressureUnit,
+ ).
+ OnChange(func() {
+ s := pressureUnitStrings()[selectedPressureUnit]
+ u, err := pressureUnitFromString(s)
+ check(err)
+
+ for i := range manifoldPressure {
+ manifoldPressure[i] = pressure{
+ manifoldPressure[i].asUnit(u),
+ u,
+ }
+ }
+ }),
+ g.InputFloat(&manifoldPressure[0].val).Format("%.2f"),
+ g.InputFloat(&manifoldPressure[1].val).Format("%.2f"),
+ g.InputFloat(&manifoldPressure[2].val).Format("%.2f"),
+ g.InputFloat(&manifoldPressure[3].val).Format("%.2f"),
+ g.InputFloat(&manifoldPressure[4].val).Format("%.2f"),
+ g.InputFloat(&manifoldPressure[5].val).Format("%.2f"),
+ )
+}