Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: IEP:688 Visualizing sensor data #702

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.espressif.idf.terminal.connector.serial.activator.Activator;
import com.espressif.idf.terminal.connector.serial.server.SocketServerHandler;
import com.espressif.idf.terminal.connector.serial.server.SocketServerMessageHandler;
import com.espressif.idf.ui.TelemetryViewerObserver;

public class SerialPortHandler
{
Expand Down Expand Up @@ -136,11 +137,14 @@ public void run()
int n;
try
{
while ((n = targetIn.read(buff, 0, buff.length)) >= 0)
while ((n = targetIn.read(buff = new byte[256], 0, buff.length)) >= 0)
{
if (n != 0)
{
System.out.println((new String(buff).replaceAll("\u0000.*", "")
.replaceAll("\u001B\\[[\\d;]*[^\\d;]", "")));
serialConnector.control.getRemoteToTerminalOutputStream().write(buff, 0, n);
TelemetryViewerObserver.updateGraphs(buff);
}
}

Expand Down
1 change: 1 addition & 0 deletions bundles/com.espressif.idf.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,4 @@ Bundle-ClassPath: .,
lib/ini4j-0.5.4.jar,
lib/gson-2.8.7.jar,
lib/commons-compress-1.21.jar
Import-Package: org.apache.commons.collections4.queue
28 changes: 28 additions & 0 deletions bundles/com.espressif.idf.ui/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,11 @@
</with>
</visibleWhen>
</command>
<command
commandId="com.espressif.idf.ui.telemetry"
label="ESP-IDF: Telemetry"
style="push">
</command>
</menuContribution>
</extension>
<extension
Expand All @@ -414,6 +419,11 @@
id="com.espressif.idf.ui.installidfcomponents"
name="%command.name.8">
</command>
<command
defaultHandler="com.espressif.idf.ui.handlers.TelemetryHandler"
id="com.espressif.idf.ui.telemetry"
name="ESP-IDF: Telemetry">
</command>
</extension>
<extension
point="org.eclipse.ui.editors">
Expand Down Expand Up @@ -534,6 +544,11 @@
id="org.eclipse.ui.commands.toggleState">
</state>
</command>
<command
defaultHandler="com.espressif.idf.ui.handlers.TelemetryHandler"
id="com.espressif.idf.ui.command.telemetry"
name="Telemetry">
</command>
</extension>
<extension
point="org.eclipse.ui.commands">
Expand Down Expand Up @@ -604,6 +619,14 @@
id="com.espressif.idf.ui.category"
name="%views_category.name">
</category>
<view
allowMultiple="true"
class="com.espressif.idf.ui.TelemetryViewer"
icon="icons/espressif.png"
id="com.espressif.idf.ui.telemetry"
name="Telemetry"
restorable="false">
</view>
</extension>
<extension
point="org.eclipse.ui.intro">
Expand Down Expand Up @@ -665,6 +688,11 @@
style="toggle"
tooltip="%command.tooltip.2">
</command>
<command
commandId="com.espressif.idf.ui.command.telemetry"
icon="icons/espressif.png"
style="push">
</command>
</toolbar>
</menuContribution>
</extension>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.espressif.idf.ui;

import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.ViewPart;

import com.espressif.idf.ui.dialogs.TelemetryGraph;
import com.espressif.idf.ui.telemetry.util.DataParser;

public class TelemetryViewer extends ViewPart
{

Composite parentComposite;

public TelemetryViewer()
{
super();
}

@Override
public void createPartControl(Composite parent)
{

parentComposite = parent;

}

public void createGraph(int cacheLimit, String graphName, String yAxisName, DataParser dataParser)
{
TelemetryGraph graph = new TelemetryGraph(parentComposite, cacheLimit, graphName, yAxisName, dataParser);
Thread grahThread = new Thread(graph);
grahThread.start();
}

@Override
public void setFocus()
{
// TODO Auto-generated method stub

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.espressif.idf.ui;

import java.util.ArrayList;
import java.util.List;

import com.espressif.idf.ui.dialogs.TelemetryGraph;

public class TelemetryViewerObserver
{
public static List<TelemetryGraph> graphs = new ArrayList<>();

public static void updateGraphs(byte[] data)
{
for (TelemetryGraph graph : graphs)
{
graph.update(data);
}
}

public static void subcribe(TelemetryGraph subscriber)
{
graphs.add(subscriber);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,23 @@ public class Messages extends NLS
public static String FilterMessage;
public static String HintsYmlNotFoundErrMsg;

public static String TelemetryDialog_CacheLimitLbl;
public static String TelemetryDialog_ColumnNumberLbl;
public static String TelemetryDialog_DataFormatLbl;
public static String TelemetryDialog_DefaultAxisY;
public static String TelemetryDialog_DefaultCacheLimit;
public static String TelemetryDialog_DefaultColumnsText;
public static String TelemetryDialog_DefaultGraphName;
public static String TelemetryDialog_DefaultSeparator;
public static String TelemetryDialog_GraphNameLbl;
public static String TelemetryDialog_Message;
public static String TelemetryDialog_RegexLbl;
public static String TelemetryDialog_SeparatorLbl;
public static String TelemetryDialog_ShellText;
public static String TelemetryDialog_Title;
public static String TelemetryDialog_TotalColumnsLbl;
public static String TelemetryDialog_YNameLbl;

static
{
// initialize resource bundle
Expand Down
Loading