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

[C#] Real time APIs #81

Merged
merged 41 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
8c375ce
Update NodeJS binding version. Make NodeJS deploy job manual
abroutin Jun 8, 2022
b31b2d8
Merge branch 'zeromq:main' into main
abroutin Jun 8, 2022
7100603
Merge branch 'main' of https://github.com/zeromq/ingescape into main
abroutin Jul 11, 2022
a4f810a
Merge branch 'main' of https://github.com/zeromq/ingescape into main
abroutin Jul 12, 2022
02e2477
Upload android, linux, mac and windows builds and installers into aut…
abroutin Jul 12, 2022
536cd8d
Fix typo
abroutin Jul 25, 2022
f50857f
Replace DEPLOYMENT_WINDOWS_NET_SHARE to WORKSPACE_NET_SHARE
abroutin Jul 25, 2022
7a67632
Remove traces of CI_PIPELINE_ID now that we have a correct PATCH vers…
Aug 4, 2022
91b7b74
Remove log message
Mathsoum Aug 4, 2022
feba5f8
Merge branch 'main' of github.com:zeromq/ingescape into main
abroutin Aug 8, 2022
bb31a19
Add Replies API into C# wrapper
abroutin Aug 30, 2022
d65e585
Merge branch 'main' of github.com:zeromq/ingescape into main
abroutin Aug 30, 2022
9627a66
Quelques Fix de crashs
abroutin Aug 30, 2022
ae88804
Mise à jour du projet de test
abroutin Aug 30, 2022
cf0f6bf
Suppression des solutions et projets visual studio. Fix compilation d…
abroutin Sep 6, 2022
a0e6031
Merge branch 'main' of github.com:zeromq/ingescape into main
abroutin Sep 6, 2022
167a363
Mise à jour CI
abroutin Sep 7, 2022
9b569c5
Merge branch 'main' of github.com:zeromq/ingescape into main
abroutin Oct 4, 2022
6819f82
Add some asserts and conditions to avoid 'read access violation' erro…
abroutin Nov 15, 2022
a4e19bb
Bad asserts
abroutin Nov 15, 2022
10f894b
Merge base
abroutin Jan 23, 2023
59e380f
[NodeJS] Mise à jour des chemins par défaut d'Ingescape
abroutin Jan 23, 2023
fa66b86
[NodeJS] Mise à jour CI
abroutin Jan 23, 2023
1c836e0
[NodeJS] Ajout du verbose pour le build windows
abroutin Jan 23, 2023
53f1737
Merge branch 'main' of github.com:zeromq/ingescape
abroutin Feb 9, 2023
a309a02
Handle event data as json in agent event callback
abroutin Feb 9, 2023
c2a886c
Update Authors
abroutin Feb 9, 2023
9c35eb4
Add a script to highlight unused ingescape methods in bindings sources
abroutin Feb 9, 2023
2c735f8
Revert
abroutin Feb 9, 2023
44fda0c
Merge branch 'main' of github.com:zeromq/ingescape
abroutin Feb 17, 2023
86c15a2
Update wrapper checker script
abroutin Feb 17, 2023
9886907
Add missing methods in C# binding
abroutin Feb 17, 2023
12ecf9d
Merge branch 'main' of github.com:zeromq/ingescape
abroutin Apr 11, 2023
3fed7b9
Merge branch 'main' of github.com:zeromq/ingescape into main
abroutin Apr 12, 2023
a1f1c49
[C#] Add missing methods
abroutin Apr 12, 2023
e62c96a
Merge branch 'main' of github.com:zeromq/ingescape
abroutin Aug 28, 2023
76ad8c2
Update ingescape.h
abroutin Aug 28, 2023
f5cfee8
Merge branch 'zeromq:main' into main
abroutin Oct 6, 2023
05ba5e2
Update test.cs
abroutin Oct 6, 2023
8dd3682
Add real-time API
abroutin Oct 6, 2023
eab0d8f
Merge branch 'main' of github.com:zeromq/ingescape
abroutin Oct 6, 2023
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
52 changes: 52 additions & 0 deletions bindings/csharp/src/Ingescape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2195,6 +2195,58 @@ public static Result ElectionLeave(string electionName)
}
#endregion

#region Ingescape real-time communications

[DllImport(ingescapeDLLPath, CallingConvention = CallingConvention.Cdecl)]
private static extern int igs_rt_get_current_timestamp();
/// <summary>
/// GET TIMESTAMP FOR RECEIVED INPUTS AND SERVICES
/// When observing an input or a service, call this function inside the callback
/// to get the current timestamp in microseconds for the received information.
/// NB: if timestamp is not available in received input or service, current
/// time in microseconds is set to INT64_MIN.
/// </summary>
public static int RtGetCurrentTimestamp() { return igs_rt_get_current_timestamp(); }


[DllImport(ingescapeDLLPath, CallingConvention = CallingConvention.Cdecl)]
private static extern void igs_rt_set_timestamps(bool enable);
/// <summary>
/// ENABLE TIMESTAMPS IN OUR AGENT FOR PUBLISHED OUTPUTS AND SERVICE CALLS
/// When timestamps are enabled, every output publication and every service call
/// carry an additional information providing the timestamp of the message on
/// the sender side. On the receiver side, timestamp is obtained by calling
/// igs_rt_get_current_timestamp
/// </summary>
public static void RtSetTimestamps(bool enable) { igs_rt_set_timestamps(enable); }

[DllImport(ingescapeDLLPath, CallingConvention = CallingConvention.Cdecl)]
private static extern bool igs_rt_timestamps();
public static bool RtTimestamps() { return igs_rt_timestamps(); }


[DllImport(ingescapeDLLPath, CallingConvention = CallingConvention.Cdecl)]
private static extern void igs_rt_set_time(int microseconds);

/// <summary>
/// SET TIME MANUALLY FOR TIMESTAMPED PUBLISHED OUTPUTS AND SERVICES
/// When a master clock is involed(e.g.linked to an input of an agent), it
/// is possible to override the automatic timestamp mechanism to force a value
/// for the current time in microseconds.
/// Once igs_rt_set_time has been called, it is necessary to continue calling it
/// periodically and manually to update the agent's current time in microseconds.
/// NB : a call to igs_rt_set_time autmatically enables timestamps for outputs
/// and services on all agents in our process.Timestamps cannot be disabled afterwards.
/// NB : igs_rt_set_time and igs_rt_time operate at peer level for all the agents
/// in the process. All agents in a process use the same time set by igs_rt_set_time.
/// </summary>
public static void RtSetTime(int microseconds) { igs_rt_set_time(microseconds); }

[DllImport(ingescapeDLLPath, CallingConvention = CallingConvention.Cdecl)]
private static extern int igs_rt_time();
public static int RtTime() { return igs_rt_time(); }
#endregion

#region Administration, logging, configuration and utilities

#region LOG ALIASES
Expand Down
33 changes: 21 additions & 12 deletions bindings/csharp/test/src/test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -602,10 +602,10 @@ public void Tester()
Assert.IsTrue(Igs.OutputType("my_data") == IopValueType.Data);
Assert.IsTrue(Igs.OutputExists("my_data"));
Assert.IsTrue(!Igs.OutputBool("my_bool"));
Assert.IsTrue(Igs.OutputInt("my_int") == 2);
Assert.IsTrue(Igs.OutputDouble("my_double") - 2.0 < 0.000001);
Assert.IsTrue(Igs.OutputInt("my_int") == 0);
Assert.IsTrue(Igs.OutputDouble("my_double") == 0.0);
outputString = Igs.OutputString("my_string");
Assert.AreEqual(outputString, "new string");
Assert.AreEqual(outputString, "");
Assert.IsTrue(Igs.OutputData("my_data").Length == 0);
listOfStrings = Igs.ParameterList();
Assert.IsTrue(listOfStrings != null && listOfStrings.Length == 6);
Expand All @@ -624,10 +624,10 @@ public void Tester()
Assert.IsTrue(Igs.ParameterType("my_data") == IopValueType.Data);
Assert.IsTrue(Igs.ParameterExists("my_data"));
Assert.IsTrue(!Igs.ParameterBool("my_bool"));
Assert.IsTrue(Igs.ParameterInt("my_int") == 2);
Assert.IsTrue(Igs.ParameterDouble("my_double") - 2.0 < 0.000001);
Assert.IsTrue(Igs.ParameterInt("my_int") == 0);
Assert.IsTrue(Igs.ParameterDouble("my_double") == 0);
parameterString = Igs.ParameterString("my_string");
Assert.AreEqual(parameterString, "new string");
Assert.AreEqual(parameterString, "");
parameterString = null;
Assert.IsTrue(Igs.ParameterData("my_data").Length == 0);
Igs.ClearDefinition();
Expand Down Expand Up @@ -670,10 +670,10 @@ public void Tester()
Assert.IsTrue(Igs.OutputType("my_data") == IopValueType.Data);
Assert.IsTrue(Igs.OutputExists("my_data"));
Assert.IsTrue(!Igs.OutputBool("my_bool"));
Assert.IsTrue(Igs.OutputInt("my_int") == 2);
Assert.IsTrue(Igs.OutputDouble("my_double") - 2.0 < 0.000001);
Assert.IsTrue(Igs.OutputInt("my_int") == 0);
Assert.IsTrue(Igs.OutputDouble("my_double") == 0);
outputString = Igs.OutputString("my_string");
Assert.AreEqual(outputString, "new string");
Assert.AreEqual(outputString, "");
outputString = null;
data = null;
Assert.IsTrue(Igs.OutputData("my_data").Length == 0);
Expand All @@ -695,10 +695,10 @@ public void Tester()
Assert.IsTrue(Igs.ParameterType("my_data") == IopValueType.Data);
Assert.IsTrue(Igs.ParameterExists("my_data"));
Assert.IsTrue(!Igs.ParameterBool("my_bool"));
Assert.IsTrue(Igs.ParameterInt("my_int") == 2);
Assert.IsTrue(Igs.ParameterDouble("my_double") - 2.0 < 0.000001);
Assert.IsTrue(Igs.ParameterInt("my_int") == 0);
Assert.IsTrue(Igs.ParameterDouble("my_double") == 0);
parameterString = Igs.ParameterString("my_string");
Assert.AreEqual(parameterString, "new string");
Assert.AreEqual(parameterString, "");
parameterString = null;
data = null;
Assert.IsTrue(Igs.ParameterData("my_data").Length == 0);
Expand Down Expand Up @@ -1405,6 +1405,15 @@ public void Tester()

FirstAgent.Destroy();
SecondAgent.Destroy();

Igs.RtSetTimestamps(true);
Assert.IsTrue(Igs.RtTimestamps());
Assert.IsTrue(Igs.RtGetCurrentTimestamp() == 0);

Igs.RtSetTimestamps(false);
Igs.RtSetTime(1000);
Igs.RtSetTimestamps(true);
Assert.IsTrue(Igs.RtTime() == 1000);
}

[TestCleanup]
Expand Down