-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Héctor Barreras Almarcha
committed
Jul 3, 2016
1 parent
374de96
commit 81bc267
Showing
5 changed files
with
139 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
module plotter; | ||
|
||
import ggplotd.ggplotd; | ||
import ggplotd.aes; | ||
import ggplotd.geom; | ||
|
||
import std.stdio; | ||
|
||
|
||
class Plotter | ||
{ | ||
private GGPlotD receivedPlot; | ||
private GGPlotD adaptedPlot; | ||
|
||
enum plotWidth = 1000; | ||
enum plotHeight = 800; | ||
|
||
this() | ||
{ | ||
|
||
} | ||
|
||
void savePlots() | ||
{ | ||
writeln("Saving plots..."); | ||
|
||
receivedPlot.save("received.png", plotWidth, plotHeight); | ||
adaptedPlot.save("adapted.png", plotWidth, plotHeight); | ||
|
||
writeln("Plots have been saved"); | ||
} | ||
|
||
void addAIRead(ubyte pin, float receivedValue, float adaptedValue, long readTimeMSecs) | ||
{ | ||
enum pinColors = ["a", "b", "c", "d", "e", "f"]; | ||
|
||
auto receivedAes = Aes!(long[], "x", float[], "y", string, "colour") | ||
([readTimeMSecs], [receivedValue], pinColors[pin]); | ||
|
||
auto adaptedAes = Aes!(long[], "x", float[], "y", string, "colour") | ||
([readTimeMSecs], [adaptedValue], pinColors[pin]); | ||
|
||
receivedPlot.put(geomPoint(receivedAes)); | ||
adaptedPlot.put(geomPoint(adaptedAes)); | ||
} | ||
|
||
void addVarMonitorRead(T)(ubyte varIndex, T receivedValue, T adaptedValue, long mSecs) | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
module puppeteer_listener; | ||
|
||
import plotter; | ||
|
||
import std.concurrency; | ||
import std.stdio; | ||
|
||
public shared class PuppeteerListener | ||
{ | ||
__gshared Tid drawer; | ||
|
||
this() | ||
{ | ||
drawer = spawn(&drawLoop); | ||
} | ||
|
||
public void finish() | ||
{ | ||
drawer.send(cast(int)0); | ||
} | ||
|
||
public void AIListener(ubyte pin, float realValue, float adaptedValue, long mSecs) | ||
{ | ||
drawer.send(DrawAIMessage(pin, realValue, adaptedValue, mSecs)); | ||
} | ||
|
||
public void varListener(T)(ubyte varIndex, T realValue, T adaptedValue, long mSecs) | ||
{ | ||
|
||
} | ||
} | ||
|
||
void drawLoop() | ||
{ | ||
Plotter plotter = new Plotter(); | ||
|
||
bool shouldLoop = true; | ||
while(shouldLoop) | ||
{ | ||
receive( | ||
(DrawAIMessage msg) {plotter.addAIRead(msg.pin, msg.realValue, msg.adaptedValue, msg.mSecs);}, | ||
(int i) {if (i==0) shouldLoop = false;} | ||
); | ||
} | ||
|
||
writeln("Finishing drawLoop"); | ||
plotter.savePlots(); | ||
} | ||
|
||
private struct DrawAIMessage | ||
{ | ||
ubyte pin; | ||
float realValue; | ||
float adaptedValue; | ||
long mSecs; | ||
} |