going with simpler java

only:proteus_f7
This commit is contained in:
rusEFI LLC 2024-11-01 12:31:07 -04:00
parent d991f73dec
commit 69c3c57a67
4 changed files with 24 additions and 23 deletions

View File

@ -2,6 +2,7 @@ package com.rusefi.ts_plugin;
import com.efiAnalytics.plugin.ecu.ControllerAccess;
import com.efiAnalytics.plugin.ecu.ControllerException;
import com.efiAnalytics.plugin.ecu.ControllerParameter;
import com.efiAnalytics.plugin.ecu.OutputChannelClient;
import com.rusefi.core.ui.AutoupdateUtil;
import org.putgemin.VerticalFlowLayout;
@ -12,6 +13,7 @@ import java.awt.event.*;
import java.util.Arrays;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class KnockAnalyzerTab {
@ -33,7 +35,6 @@ public class KnockAnalyzerTab {
private final KnockMagnitudeCanvas magnituges = new KnockMagnitudeCanvas();
public KnockAnalyzerTab(Supplier<ControllerAccess> controllerAccessSupplier) {
var cc = this;
this.controllerAccessSupplier = controllerAccessSupplier;
this.setStartButtonState();
@ -72,7 +73,7 @@ public class KnockAnalyzerTab {
try {
String[] outputChannelNames = this.controllerAccessSupplier.get().getOutputChannelServer().getOutputChannels(ecuControllerName);
var spectrums = Arrays.stream(outputChannelNames)
String[] spectrums = Arrays.stream(outputChannelNames)
.filter((n) -> n.indexOf("m_knockSpectrum") >= 0)
.collect(Collectors.toList())
.toArray(new String[0]);
@ -82,14 +83,14 @@ public class KnockAnalyzerTab {
button.setText(this.getEnabled() == "true" ? "Stop" : "Start");
int checksum = 0;
for(var i = 0; i< 16; ++i) {
for (int i = 0; i< 16; ++i) {
checksum += i;
}
for(var i = 0; i< 16; ++i){
for (int i = 0; i< 16; ++i){
try {
var name = spectrums[i];
String name = spectrums[i];
int finalChecksum = checksum;
controllerAccessSupplier.get().getOutputChannelServer().subscribe(ecuControllerName, name, new OutputChannelClient() {
@Override
@ -103,8 +104,8 @@ public class KnockAnalyzerTab {
return;
}
var indexStr = name.substring(15);
var index = Integer.parseInt(indexStr) - 1;
String indexStr = name.substring(15);
int index = Integer.parseInt(indexStr) - 1;
//values[index] = (int)v;
long value = (long)v;
@ -151,8 +152,8 @@ public class KnockAnalyzerTab {
long value = (long)v;
cc.channel = (int)(value >>> 8) & 0xFF;
cc.cylinder = (int)(value & 0xFF);
KnockAnalyzerTab.this.channel = (int)(value >>> 8) & 0xFF;
KnockAnalyzerTab.this.cylinder = (int)(value & 0xFF);
}
});
@ -165,7 +166,7 @@ public class KnockAnalyzerTab {
public void actionPerformed(ActionEvent e) {
try {
var started = cc.setStartButtonState();
boolean started = KnockAnalyzerTab.this.setStartButtonState();
controllerAccessSupplier.get().getControllerParameterServer().updateParameter(ecuControllerName, "enableKnockSpectrogram", started ? 1.0 : 0.0);
} catch (ControllerException ee) {
System.out.println(ee.getMessage());
@ -219,7 +220,7 @@ public class KnockAnalyzerTab {
public String getEnabled() {
try {
String ecuControllerName = this.controllerAccessSupplier.get().getEcuConfigurationNames()[0];
var enable = controllerAccessSupplier.get().getControllerParameterServer().getControllerParameter(ecuControllerName, "enableKnockSpectrogram");
ControllerParameter enable = controllerAccessSupplier.get().getControllerParameterServer().getControllerParameter(ecuControllerName, "enableKnockSpectrogram");
String enabled = enable.getStringValue();
return enabled;
} catch (ControllerException ee) {

View File

@ -39,12 +39,12 @@ public class KnockCanvas {
g.setColor(Color.YELLOW);
for(int i = 0; i < yAxisHz.length; ++i) {
var y = hzToYScreen(yAxisHz[i], height);
int y = hzToYScreen(yAxisHz[i], height);
g.setColor(Color.orange);
g.fillRect(0, y, 30, 1);
var hz = yAxisHz[i];
double hz = yAxisHz[i];
g.drawString(Double.valueOf(round(hz, 1)).toString(), 35, y);
}
@ -59,7 +59,7 @@ public class KnockCanvas {
g.setFont(new Font(f.getName(), Font.BOLD, g.getFont().getSize()));
g.setColor(Color.YELLOW);
var currentX = width / 4;
int currentX = width / 4;
g.drawString("[current]", currentX, 10);
g.drawString(Float.valueOf(currentFrequency).toString() + " Hz", currentX, 30);
g.drawString(Float.valueOf(currentAmplitude).toString() + " Amp", currentX, 50);
@ -81,7 +81,7 @@ public class KnockCanvas {
g.setColor(Color.WHITE);
var yy = hzToYScreen(currentFrequency, height);
int yy = hzToYScreen(currentFrequency, height);
g.fillRect(0, yy, width, 1);
g.setColor(Color.DARK_GRAY);
@ -203,7 +203,7 @@ public class KnockCanvas {
return;
}
for(var i = 0; i < 64; ++i) {
for (int i = 0; i < 64; ++i) {
float y = (float)this.yAxisFequencyStart + (this.yAxisFequencyStep * (float)i);
this.yAxisHz[i] = y;
}
@ -302,10 +302,10 @@ public class KnockCanvas {
//simple draw
bufferedGraphics.setColor(color);
var yr = height - (height / spectrogramYAxisSize) * y;
var xr = (int)(currentIndexXAxis * bx);
var widthr = ((int)bx) + 1;
var heightr = (height / spectrogramYAxisSize);
int yr = height - (height / spectrogramYAxisSize) * y;
int xr = (int)(currentIndexXAxis * bx);
int widthr = ((int)bx) + 1;
int heightr = (height / spectrogramYAxisSize);
bufferedGraphics.fillRect(xr, yr, widthr, heightr);
}
@ -348,7 +348,7 @@ public class KnockCanvas {
int hzToYScreen(double hz, int screen_height) {
var near_hz_index = searchHZ(yAxisHz, 0, yAxisHz.length - 1, hz);
int near_hz_index = searchHZ(yAxisHz, 0, yAxisHz.length - 1, hz);
int a = near_hz_index-1;
int b = near_hz_index;

View File

@ -99,7 +99,7 @@ public class KnockMagnitudeCanvas {
return;
}
for (var i = 0; i < 64; ++i) {
for (int i = 0; i < 64; ++i) {
float y = (float) this.yAxisFequencyStart + (this.yAxisFequencyStep * (float) i);
this.yAxisHz[i] = y;
}

View File

@ -41,7 +41,7 @@ public class LogUploadSelector {
JPanel filePanel = new JPanel(new BorderLayout());
filePanel.add(fileList, BorderLayout.CENTER);
var screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
fileList.setMaximumSize(new Dimension((int)(screenSize.width / 1.3), 800));
fileList.setPreferredSize(new Dimension((int)(screenSize.width / 1.3), 800));