diff --git a/Messages/BinaryMsg.cs b/Messages/BinaryMsg.cs
index e72c6fd..fb5d76c 100644
--- a/Messages/BinaryMsg.cs
+++ b/Messages/BinaryMsg.cs
@@ -21,6 +21,9 @@ namespace Passer.RoboidControl {
/// The ID of the thing
///
public byte thingId;
+
+ public Thing thing;
+
///
/// The binary data
///
@@ -45,7 +48,8 @@ namespace Passer.RoboidControl {
public BinaryMsg(byte networkId, Thing thing) : base() {
this.networkId = networkId;
this.thingId = thing.id;
- this.bytes = System.Array.Empty();
+ this.thing = thing;
+ this.bytes = this.thing.GenerateBinary();
}
/// @copydoc Passer::RoboidControl::IMessage::IMessage(byte[] buffer)
public BinaryMsg(byte[] buffer) {
@@ -59,7 +63,7 @@ namespace Passer.RoboidControl {
}
/// @copydoc Passer::RoboidControl::IMessage::Serialize
- public override byte Serialize(ref byte[] buffer) {
+ public override byte Serialize(ref byte[] buffer) {
if (buffer.Length < BinaryMsg.length + this.bytes.Length || this.bytes.Length == 0)
return 0;
diff --git a/Participant.cs b/Participant.cs
index 349f50d..286cf78 100644
--- a/Participant.cs
+++ b/Participant.cs
@@ -27,7 +27,7 @@ namespace Passer.RoboidControl {
/// Create a porticiapnt
///
public Participant() {
- senders.Add(this);
+ //senders.Add(this);
}
///
@@ -77,7 +77,7 @@ namespace Passer.RoboidControl {
return null;
}
public RemoteParticipant AddParticipant(string ipAddress, int port) {
- // Console.WriteLine($"New Participant {ipAddress}:{port}");
+ Console.WriteLine($"New Participant {ipAddress}:{port}");
RemoteParticipant participant = new RemoteParticipant(ipAddress, port) {
networkId = (byte)this.senders.Count
};
@@ -144,8 +144,12 @@ namespace Passer.RoboidControl {
int n = this.things.Count;
for (int ix = 0; ix < n; ix++) {
Thing thing = this.things[ix];
- if (thing != null) // && thing.parent == null) // update only root things
+ if (thing != null) {
thing.Update(currentTimeMS);
+ BinaryMsg binaryMsg = new(this.networkId, thing);
+ foreach (RemoteParticipant sender in this.senders)
+ this.Send(sender, binaryMsg);
+ }
}
}
diff --git a/Sensors/TouchSensor.cs b/Sensors/TouchSensor.cs
index f6bc873..6ea7f77 100644
--- a/Sensors/TouchSensor.cs
+++ b/Sensors/TouchSensor.cs
@@ -7,7 +7,15 @@ namespace Passer.RoboidControl {
///
/// Value which is true when the sensor is touching something, false otherwise
///
- public bool touchedSomething = false;
+ //public bool touchedSomething = false;
+ private bool _touchedSomething = false;
+ public bool touchedSomething {
+ get { return _touchedSomething; }
+ set {
+ _touchedSomething = value;
+ //SendBinary();
+ }
+ }
///
/// Create a touch sensor
@@ -30,5 +38,10 @@ namespace Passer.RoboidControl {
this.component.core = this;
}
#endif
+ public override byte[] GenerateBinary() {
+ byte[] buffer = new byte[1];
+ buffer[0] = (byte)(touchedSomething ? 1 : 0);
+ return buffer;
+ }
}
}
\ No newline at end of file