-
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.
Prepare to test the csharp library; removed all the dependencies from…
… the PinakothekDrawing c#-project
- Loading branch information
Andrei Costinescu
committed
May 22, 2021
1 parent
f3ed26b
commit 4332d86
Showing
9 changed files
with
648 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,9 @@ | |
*__pycache__* | ||
*.pyc | ||
|
||
*.vs | ||
|
||
csharp/*.sln | ||
csharp/*.csproj | ||
csharp/bin | ||
csharp/obj |
Large diffs are not rendered by default.
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
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,28 @@ | ||
using System; | ||
|
||
namespace Comm.utils { | ||
public class DebugUtils { | ||
private static DebugUtils defaultDebugUtilsImplementation = new DebugUtils(); | ||
private static DebugUtils debugUtilsImplementation; | ||
|
||
public virtual void SetOutputImpl(string message) { | ||
Console.WriteLine(message); | ||
} | ||
|
||
public static void SetDebugImplementation(DebugUtils debugUtilsImplementation) { | ||
DebugUtils.debugUtilsImplementation = debugUtilsImplementation; | ||
} | ||
|
||
public static void ResetDebugImplementation() { | ||
DebugUtils.debugUtilsImplementation = null; | ||
} | ||
|
||
public static void SetOutput(string message) { | ||
if (DebugUtils.debugUtilsImplementation == null) { | ||
DebugUtils.defaultDebugUtilsImplementation.SetOutputImpl(message); | ||
} else { | ||
DebugUtils.debugUtilsImplementation.SetOutputImpl(message); | ||
} | ||
} | ||
} | ||
} |
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,13 @@ | ||
namespace Comm.utils { | ||
public class Reference<T> { | ||
private T v; | ||
public T Value { | ||
get => this.v; | ||
set { | ||
this.v = value; | ||
} | ||
} | ||
|
||
public Reference() { } | ||
} | ||
} |
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,65 @@ | ||
using Comm.communication; | ||
using Comm.data; | ||
using Comm.socket; | ||
using Comm.utils; | ||
using System; | ||
|
||
namespace Comm { | ||
public class CommunicatorApplication { | ||
public CommunicatorApplication() { | ||
this.quit = false; | ||
this.state = CommunicatorState.COMMUNICATOR_IDLE; | ||
this.dataCollection = new DataCollection(); | ||
} | ||
|
||
~CommunicatorApplication() { } | ||
|
||
public virtual void main() { | ||
while (!this.quit) { | ||
this._preMain(); | ||
try { | ||
this._main(); | ||
} catch (Exception e) { | ||
Console.WriteLine("Exception caught: " + e.ToString()); | ||
} | ||
this._postMain(); | ||
} | ||
} | ||
|
||
public virtual void stop() { | ||
this.quit = true; | ||
} | ||
|
||
protected bool send(Communication comm, SocketType socketType, CommunicationData data, int retries = 0, bool verbose = false) { | ||
return Communicator.send(comm, socketType, data, false, true, retries, verbose); | ||
} | ||
|
||
protected bool send(Communication comm, SocketType socketType, byte[] data, int dataSize, int retries = 0, bool verbose = false) { | ||
return Communicator.send(comm, socketType, data, dataSize, retries, verbose); | ||
} | ||
|
||
protected bool syphon(Communication comm, SocketType socketType, ref MessageType messageType, CommunicationData data, int retries = 0, bool verbose = false, int syphonRetries = 10) { | ||
return Communicator.syphon(comm, socketType, ref messageType, data, ref this.quit, retries, verbose); | ||
} | ||
|
||
protected bool listen(Communication comm, SocketType socketType, ref MessageType messageType, ref DataCollection _dataCollection, int retries = 0, bool verbose = false) { | ||
return Communicator.listen(comm, socketType, ref messageType, ref _dataCollection, ref this.quit, retries, verbose); | ||
} | ||
|
||
protected bool listenFor(Communication comm, SocketType socketType, CommunicationData data, | ||
Reference<bool> timeoutResult = null, int countIgnoreOther = -1, | ||
int countOther = -1, int retries = 0, bool verbose = false) { | ||
return Communicator.listenFor(comm, socketType, data, ref this.quit, timeoutResult, countIgnoreOther, countOther, retries, verbose); | ||
} | ||
|
||
protected virtual void _preMain() { } | ||
|
||
protected virtual void _main() { } | ||
|
||
protected virtual void _postMain() { } | ||
|
||
protected bool quit; | ||
protected CommunicatorState state; | ||
protected DataCollection dataCollection; | ||
}; | ||
} |
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,43 @@ | ||
using Comm.data; | ||
using System; | ||
|
||
namespace Comm { | ||
public class CoordinateGetter { | ||
public CoordinateGetter() { | ||
this.x = 0.5; | ||
this.y = 0.5; | ||
this.touch = true; | ||
this.buttonFwd = false; | ||
this.buttonDwn = false; | ||
this.startTime = DateTime.Now; | ||
} | ||
|
||
~CoordinateGetter() { } | ||
|
||
public void resetDrawingArea(bool withTimeReset = true) { | ||
if (withTimeReset) { | ||
this.startTime = DateTime.Now; | ||
} | ||
} | ||
|
||
public void setData(float x, float y, bool touch) { | ||
this.x = x; | ||
this.y = y; | ||
this.touch = touch; | ||
} | ||
|
||
public bool getData(CoordinateData data) { | ||
data.set("touch", this.touch); | ||
data.set("buttonFwd", this.buttonFwd); | ||
data.set("buttonDwn", this.buttonDwn); | ||
data.set("x", x); | ||
data.set("y", y); | ||
data.set("time", (long)(DateTime.Now - this.startTime).Milliseconds); | ||
return true; | ||
} | ||
|
||
double x, y; | ||
bool buttonFwd, buttonDwn, touch; | ||
DateTime startTime; | ||
}; | ||
} |
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