diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..b92d56a Binary files /dev/null and b/.DS_Store differ diff --git a/DoxyGen/DoxyWarnLogfile.txt b/DoxyGen/DoxyWarnLogfile.txt index b50dcf0..1af2fe9 100644 --- a/DoxyGen/DoxyWarnLogfile.txt +++ b/DoxyGen/DoxyWarnLogfile.txt @@ -1,39 +1,51 @@ -warning: source 'images' is not a readable file or directory... skipping. -d:/Python/Control.Core/ClientMsg.py:16: warning: Member network_id (variable) of class Control.Core.ClientMsg.ClientMsg is not documented. -d:/Python/Control.Core/ClientMsg.py:8: warning: Member id (variable) of class Control.Core.ClientMsg.ClientMsg is not documented. -d:/Python/Control.Core/ClientMsg.py:9: warning: Member length (variable) of class Control.Core.ClientMsg.ClientMsg is not documented. -d:/Python/Control.Core/Participant.py:9: warning: Member __init__(self, ipAddress="0.0.0.0", port=7168) (function) of class Control.Core.Participant.Participant is not documented. -d:/Python/Control.Core/Participant.py:48: warning: Member Publish(self, msg) (function) of class Control.Core.Participant.Participant is not documented. -d:/Python/Control.Core/Participant.py:56: warning: Member Update(self, currentTime) (function) of class Control.Core.Participant.Participant is not documented. -d:/Python/Control.Core/Participant.py:64: warning: Member ProcessClientMsg(self, bytearray data) (function) of class Control.Core.Participant.Participant is not documented. -d:/Python/Control.Core/Participant.py:66: warning: Member ProcessNetworkIdMsg(self, bytearray data) (function) of class Control.Core.Participant.Participant is not documented. -d:/Python/Control.Core/Participant.py:68: warning: Member ProcessInvestigateMsg(self, bytearray data) (function) of class Control.Core.Participant.Participant is not documented. -d:/Python/Control.Core/Participant.py:71: warning: Member ReceiveData(self, data) (function) of class Control.Core.Participant.Participant is not documented. -d:/Python/Control.Core/Participant.py:10: warning: Member buffer (variable) of class Control.Core.Participant.Participant is not documented. -d:/Python/Control.Core/Participant.py:11: warning: Member ipAddress (variable) of class Control.Core.Participant.Participant is not documented. -d:/Python/Control.Core/Participant.py:12: warning: Member port (variable) of class Control.Core.Participant.Participant is not documented. -d:/Python/Control.Core/Participant.py:13: warning: Member udp_socket (variable) of class Control.Core.Participant.Participant is not documented. -d:/Python/Control.Core/Participant.py:18: warning: Member network_id (variable) of class Control.Core.Participant.Participant is not documented. -d:/Python/Control.Core/Participant.py:19: warning: Member nextPublishMe (variable) of class Control.Core.Participant.Participant is not documented. -d:/Python/Control.Core/Participant.py:8: warning: Member publishInterval (variable) of class Control.Core.Participant.Participant is not documented. -d:/Python/Control.Core/Thing.py:20: warning: Member __init__(self, type=Type.Undetermined, parent=None, name=None) (function) of class Control.Core.Thing.Thing is not documented. -d:/Python/Control.Core/Thing.py:41: warning: Member update(self, currentTime) (function) of class Control.Core.Thing.Thing is not documented. -d:/Python/Control.Core/Thing.py:44: warning: Member ProcessBinary(self, data) (function) of class Control.Core.Thing.Thing is not documented. -d:/Python/Control.Core/Thing.py:50: warning: Member Add(thing) (function) of class Control.Core.Thing.Thing is not documented. -d:/Python/Control.Core/Thing.py:55: warning: Member Get(networkId, thingId) (function) of class Control.Core.Thing.Thing is not documented. -d:/Python/Control.Core/Thing.py:21: warning: Member networkId (variable) of class Control.Core.Thing.Thing is not documented. -d:/Python/Control.Core/Thing.py:22: warning: Member id (variable) of class Control.Core.Thing.Thing is not documented. -d:/Python/Control.Core/Thing.py:23: warning: Member type (variable) of class Control.Core.Thing.Thing is not documented. -d:/Python/Control.Core/Thing.py:25: warning: Member parent_id (variable) of class Control.Core.Thing.Thing is not documented. -d:/Python/Control.Core/Thing.py:29: warning: Member name (variable) of class Control.Core.Thing.Thing is not documented. -d:/Python/Control.Core/Thing.py:30: warning: Member model_url (variable) of class Control.Core.Thing.Thing is not documented. -d:/Python/Control.Core/Thing.py:32: warning: Member position (variable) of class Control.Core.Thing.Thing is not documented. -d:/Python/Control.Core/Thing.py:33: warning: Member orientation (variable) of class Control.Core.Thing.Thing is not documented. -d:/Python/Control.Core/Thing.py:34: warning: Member linearVelocity (variable) of class Control.Core.Thing.Thing is not documented. -d:/Python/Control.Core/Thing.py:35: warning: Member angularVelocity (variable) of class Control.Core.Thing.Thing is not documented. -d:/Python/Control.Core/Thing.py:37: warning: Member pose_updated (variable) of class Control.Core.Thing.Thing is not documented. -d:/Python/Control.Core/Thing.py:15: warning: Member Position (variable) of class Control.Core.Thing.Thing is not documented. -d:/Python/Control.Core/Thing.py:16: warning: Member Orientation (variable) of class Control.Core.Thing.Thing is not documented. -d:/Python/Control.Core/Thing.py:17: warning: Member LinearVelocity (variable) of class Control.Core.Thing.Thing is not documented. -d:/Python/Control.Core/Thing.py:18: warning: Member AngularVelocity (variable) of class Control.Core.Thing.Thing is not documented. -d:/Python/Control.Core/Thing.py:47: warning: Member allThings (variable) of class Control.Core.Thing.Thing is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:31: warning: documented symbol 'controlcore.Participant.Participant::bool' was not declared or defined. +error: Project logo '//intranet/home/Afbeeldingen/PasserVR/Logos/Logo3NameRight100.png' specified by PROJECT_LOGO does not exist! +/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:26: warning: Member __init__(self, ipAddress="0.0.0.0", port=7681, remote=False, udp_socket=None) (function) of class controlcore.Participant.Participant is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:47: warning: Member GetParticipant(self, ip_address, port) (function) of class controlcore.Participant.Participant is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:57: warning: Member AddParticipant(self, ip_address, port) (function) of class controlcore.Participant.Participant is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:64: warning: Member Update(self, currentTimeMs) (function) of class controlcore.Participant.Participant is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:76: warning: Member SendThingInfo(self, thing) (function) of class controlcore.Participant.Participant is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:81: warning: Member Send(self, msg) (function) of class controlcore.Participant.Participant is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:90: warning: Member Publish(self, msg) (function) of class controlcore.Participant.Participant is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:103: warning: Member Receiver(self) (function) of class controlcore.Participant.Participant is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:115: warning: Member ReceiveData(self, data, remote_participant) (function) of class controlcore.Participant.Participant is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:135: warning: Member ProcessClientMsg(self, sender, ParticipantMsg msg) (function) of class controlcore.Participant.Participant is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:138: warning: Member ProcessNetworkIdMsg(self, sender, NetworkIdMsg msg) (function) of class controlcore.Participant.Participant is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:147: warning: Member ProcessInvestigateMsg(self, bytearray data) (function) of class controlcore.Participant.Participant is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:150: warning: Member ProcessThingMsg(self, ThingMsg msg) (function) of class controlcore.Participant.Participant is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:153: warning: Member ProcessNameMsg(self, NameMsg msg) (function) of class controlcore.Participant.Participant is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:156: warning: Member ProcessModelUrlMsg(self, ModelUrlMsg msg) (function) of class controlcore.Participant.Participant is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:27: warning: Member ip_address (variable) of class controlcore.Participant.Participant is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:28: warning: Member port (variable) of class controlcore.Participant.Participant is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:34: warning: Member udp_socket (variable) of class controlcore.Participant.Participant is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:16: warning: Member publishInterval (variable) of class controlcore.Participant.Participant is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:18: warning: Member buffer (variable) of class controlcore.Participant.Participant is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:21: warning: Member nextPublishMe (variable) of class controlcore.Participant.Participant is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:22: warning: Member others (variable) of class controlcore.Participant.Participant is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:23: warning: Member thread (variable) of class controlcore.Participant.Participant is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Participant.py:24: warning: Member name (variable) of class controlcore.Participant.Participant is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:21: warning: Member __init__(self, type=Type.Undetermined, parent=None, name=None) (function) of class controlcore.Thing.Thing is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:42: warning: Member update(self, currentTime) (function) of class controlcore.Thing.Thing is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:45: warning: Member ProcessBinary(self, data) (function) of class controlcore.Thing.Thing is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:51: warning: Member Add(thing) (function) of class controlcore.Thing.Thing is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:56: warning: Member Get(networkId, thingId) (function) of class controlcore.Thing.Thing is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:22: warning: Member networkId (variable) of class controlcore.Thing.Thing is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:23: warning: Member id (variable) of class controlcore.Thing.Thing is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:24: warning: Member type (variable) of class controlcore.Thing.Thing is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:26: warning: Member parent_id (variable) of class controlcore.Thing.Thing is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:30: warning: Member name (variable) of class controlcore.Thing.Thing is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:31: warning: Member model_url (variable) of class controlcore.Thing.Thing is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:33: warning: Member position (variable) of class controlcore.Thing.Thing is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:34: warning: Member orientation (variable) of class controlcore.Thing.Thing is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:35: warning: Member linearVelocity (variable) of class controlcore.Thing.Thing is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:36: warning: Member angularVelocity (variable) of class controlcore.Thing.Thing is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:38: warning: Member pose_updated (variable) of class controlcore.Thing.Thing is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:16: warning: Member Position (variable) of class controlcore.Thing.Thing is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:17: warning: Member Orientation (variable) of class controlcore.Thing.Thing is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:18: warning: Member LinearVelocity (variable) of class controlcore.Thing.Thing is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:19: warning: Member AngularVelocity (variable) of class controlcore.Thing.Thing is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Thing.py:48: warning: Member allThings (variable) of class controlcore.Thing.Thing is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Messages/NetworkIdMsg.py:7: warning: Member id (variable) of class NetworkIdMsg.NetworkIdMsg is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Messages/NetworkIdMsg.py:8: warning: Member length (variable) of class NetworkIdMsg.NetworkIdMsg is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/Messages/NetworkIdMsg.py:10: warning: Member network_id (variable) of class NetworkIdMsg.NetworkIdMsg is not documented. +/Users/pascal/Documents/Dev/Python/controlcore/LinearAlgebra/SwingTwist.py:6: warning: Member __init__(self, Direction swing, float twist) (function) of class SwingTwist.SwingTwist is not documented. diff --git a/Direction.py b/LinearAlgebra/Direction.py similarity index 100% rename from Direction.py rename to LinearAlgebra/Direction.py diff --git a/Quaternion.py b/LinearAlgebra/Quaternion.py similarity index 100% rename from Quaternion.py rename to LinearAlgebra/Quaternion.py diff --git a/Spherical.py b/LinearAlgebra/Spherical.py similarity index 96% rename from Spherical.py rename to LinearAlgebra/Spherical.py index 75fe54a..110eea5 100644 --- a/Spherical.py +++ b/LinearAlgebra/Spherical.py @@ -1,5 +1,5 @@ import math -from Direction import Direction +from LinearAlgebra.Direction import Direction class Spherical: def __init__(self, distance, direction): diff --git a/SwingTwist.py b/LinearAlgebra/SwingTwist.py similarity index 62% rename from SwingTwist.py rename to LinearAlgebra/SwingTwist.py index 5e0c893..206616c 100644 --- a/SwingTwist.py +++ b/LinearAlgebra/SwingTwist.py @@ -1,17 +1,21 @@ -from Direction import Direction -from Quaternion import Quaternion +from LinearAlgebra.Direction import Direction +from LinearAlgebra.Quaternion import Quaternion class SwingTwist: + """A rotation using swing and twist angle components""" def __init__(self, swing: Direction, twist: float): if swing.vertical > 90 or swing.vertical < -90: swing.horizontal += 180 swing.vertical = 180 - swing.vertical twist += 180 + ## Swing component of the rotation self.swing = swing + ## The twist component of the rotation self.twist = twist def ToQuaternion(self) -> Quaternion: + """Convert the SwingTwist rotation to a Quaternion""" q = Quaternion.Euler(-self.swing.vertical, self.swing.horizontal, self.twist) diff --git a/LinearAlgebra/__pycache__/Direction.cpython-312.pyc b/LinearAlgebra/__pycache__/Direction.cpython-312.pyc new file mode 100644 index 0000000..cfa819d Binary files /dev/null and b/LinearAlgebra/__pycache__/Direction.cpython-312.pyc differ diff --git a/LinearAlgebra/__pycache__/Quaternion.cpython-312.pyc b/LinearAlgebra/__pycache__/Quaternion.cpython-312.pyc new file mode 100644 index 0000000..202f63c Binary files /dev/null and b/LinearAlgebra/__pycache__/Quaternion.cpython-312.pyc differ diff --git a/LinearAlgebra/__pycache__/Spherical.cpython-312.pyc b/LinearAlgebra/__pycache__/Spherical.cpython-312.pyc new file mode 100644 index 0000000..44b9330 Binary files /dev/null and b/LinearAlgebra/__pycache__/Spherical.cpython-312.pyc differ diff --git a/LinearAlgebra/__pycache__/SwingTwist.cpython-312.pyc b/LinearAlgebra/__pycache__/SwingTwist.cpython-312.pyc new file mode 100644 index 0000000..35a692c Binary files /dev/null and b/LinearAlgebra/__pycache__/SwingTwist.cpython-312.pyc differ diff --git a/LowLevelMessages.py b/Messages/LowLevelMessages.py similarity index 96% rename from LowLevelMessages.py rename to Messages/LowLevelMessages.py index 5545141..f91a5e7 100644 --- a/LowLevelMessages.py +++ b/Messages/LowLevelMessages.py @@ -1,5 +1,5 @@ import numpy as np -from SwingTwist import SwingTwist +from LinearAlgebra.SwingTwist import SwingTwist def SendAngle8(buffer, ix_ref, angle): # Normalize angle diff --git a/Messages.py b/Messages/Messages.py similarity index 97% rename from Messages.py rename to Messages/Messages.py index 4aff96f..fc049dd 100644 --- a/Messages.py +++ b/Messages/Messages.py @@ -1,4 +1,4 @@ -import LowLevelMessages +import Messages.LowLevelMessages as LowLevelMessages from Thing import Thing class IMessage: diff --git a/ModelUrlMsg.py b/Messages/ModelUrlMsg.py similarity index 96% rename from ModelUrlMsg.py rename to Messages/ModelUrlMsg.py index bd670e2..5cc835e 100644 --- a/ModelUrlMsg.py +++ b/Messages/ModelUrlMsg.py @@ -1,4 +1,4 @@ -from Messages import IMessage +from Messages.Messages import IMessage class ModelUrlMsg(IMessage): id = 0x90 diff --git a/NameMsg.py b/Messages/NameMsg.py similarity index 96% rename from NameMsg.py rename to Messages/NameMsg.py index 5acb8bd..409f8b4 100644 --- a/NameMsg.py +++ b/Messages/NameMsg.py @@ -1,4 +1,4 @@ -from Messages import IMessage +from Messages.Messages import IMessage class NameMsg(IMessage): id = 0x91 diff --git a/NetworkIdMsg.py b/Messages/NetworkIdMsg.py similarity index 97% rename from NetworkIdMsg.py rename to Messages/NetworkIdMsg.py index 280fae5..d5f455d 100644 --- a/NetworkIdMsg.py +++ b/Messages/NetworkIdMsg.py @@ -1,4 +1,4 @@ -from Messages import IMessage +from Messages.Messages import IMessage ## A network id message invites another participant to a site # diff --git a/ClientMsg.py b/Messages/ParticipantMsg.py similarity index 58% rename from ClientMsg.py rename to Messages/ParticipantMsg.py index a431436..f665cf8 100644 --- a/ClientMsg.py +++ b/Messages/ParticipantMsg.py @@ -1,39 +1,41 @@ -from Messages import IMessage +from Messages.Messages import IMessage -## A client message announces the presence of a participant -# -## When received by another participant, it can be followed by a NetworkIdMsg -## to announce that participant to this client such that it can join privately -class ClientMsg(IMessage): - id = 0xA0 - length = 2 +class ParticipantMsg(IMessage): + """! A participant messages notifies other participants of its presence. - network_id = None + When received by another participant, it can be followed by a NetworkIdMsg + to announce that participant to this client such that it can join privately + """ + ## The message ID + id: int = 0xA0 + ## The length of the message + length: int = 2 + ## The network ID known by the participant. + network_id: int = None - ## Create a Client message - # - # @param network_id The network id of the local participant. Use 0 if it is unknown - def __init__(self, network_id): - + def __init__(self, network_id: int): + """! Create a new message for sending + @param network_id The network ID known by the participant. Use 0 if it is unknown + """ if isinstance(network_id, int): self.network_id = network_id elif isinstance(network_id, bytes): self.network_id = network_id[1] - ## Serialize the message into the given buffer - # - ## @param buffer_ref A reference to the buffer to use. This should be a list with the buffer as its first and only element - ## @returns the length of the message def Serialize(self, buffer_ref): + """! Serialize the message into a byte array. + @param buffer_ref The buffer to serialize into + @return The length of the message in the buffer + """ if buffer_ref is None or self.network_id is None: return 0 buffer: bytearray = buffer_ref[0] - buffer[0:ClientMsg.length] = [ - ClientMsg.id, + buffer[0:ParticipantMsg.length] = [ + ParticipantMsg.id, self.network_id ] - return ClientMsg.length + return ParticipantMsg.length # @staticmethod # def Serialized(buffer_ref, network_id): diff --git a/ThingMsg.py b/Messages/ThingMsg.py similarity index 96% rename from ThingMsg.py rename to Messages/ThingMsg.py index b97f597..262d414 100644 --- a/ThingMsg.py +++ b/Messages/ThingMsg.py @@ -1,4 +1,4 @@ -from Messages import IMessage +from Messages.Messages import IMessage class ThingMsg(IMessage): id = 0x80 diff --git a/Messages/__pycache__/ClientMsg.cpython-312.pyc b/Messages/__pycache__/ClientMsg.cpython-312.pyc new file mode 100644 index 0000000..2e62506 Binary files /dev/null and b/Messages/__pycache__/ClientMsg.cpython-312.pyc differ diff --git a/Messages/__pycache__/LowLevelMessages.cpython-312.pyc b/Messages/__pycache__/LowLevelMessages.cpython-312.pyc new file mode 100644 index 0000000..03f709f Binary files /dev/null and b/Messages/__pycache__/LowLevelMessages.cpython-312.pyc differ diff --git a/Messages/__pycache__/Messages.cpython-312.pyc b/Messages/__pycache__/Messages.cpython-312.pyc new file mode 100644 index 0000000..a970eee Binary files /dev/null and b/Messages/__pycache__/Messages.cpython-312.pyc differ diff --git a/Messages/__pycache__/ModelUrlMsg.cpython-312.pyc b/Messages/__pycache__/ModelUrlMsg.cpython-312.pyc new file mode 100644 index 0000000..ae56611 Binary files /dev/null and b/Messages/__pycache__/ModelUrlMsg.cpython-312.pyc differ diff --git a/Messages/__pycache__/NameMsg.cpython-312.pyc b/Messages/__pycache__/NameMsg.cpython-312.pyc new file mode 100644 index 0000000..914bec7 Binary files /dev/null and b/Messages/__pycache__/NameMsg.cpython-312.pyc differ diff --git a/Messages/__pycache__/NetworkIdMsg.cpython-312.pyc b/Messages/__pycache__/NetworkIdMsg.cpython-312.pyc new file mode 100644 index 0000000..5d3f633 Binary files /dev/null and b/Messages/__pycache__/NetworkIdMsg.cpython-312.pyc differ diff --git a/Messages/__pycache__/ParticipantMsg.cpython-312.pyc b/Messages/__pycache__/ParticipantMsg.cpython-312.pyc new file mode 100644 index 0000000..60a3e4c Binary files /dev/null and b/Messages/__pycache__/ParticipantMsg.cpython-312.pyc differ diff --git a/Messages/__pycache__/ThingMsg.cpython-312.pyc b/Messages/__pycache__/ThingMsg.cpython-312.pyc new file mode 100644 index 0000000..bd7b968 Binary files /dev/null and b/Messages/__pycache__/ThingMsg.cpython-312.pyc differ diff --git a/Participant.py b/Participant.py index 9d1fc3a..f2d5c86 100644 --- a/Participant.py +++ b/Participant.py @@ -1,20 +1,22 @@ import socket import threading -from ClientMsg import ClientMsg -from NetworkIdMsg import NetworkIdMsg -from ThingMsg import ThingMsg -from NameMsg import NameMsg -from ModelUrlMsg import ModelUrlMsg +from Messages.ParticipantMsg import ParticipantMsg +from Messages.NetworkIdMsg import NetworkIdMsg +from Messages.ThingMsg import ThingMsg +from Messages.NameMsg import NameMsg +from Messages.ModelUrlMsg import ModelUrlMsg from Thing import Thing -## A participant is device which can communicate with other participants -# -## Currently only UDP communication is supported class Participant: + """! A participant is used for communcation between things. + + Currently, only UDP communication is supported + """ publishInterval = 3000 # 3 seconds buffer = None + ## The network ID of the participant network_id = None nextPublishMe = 0 others = None @@ -61,7 +63,7 @@ class Participant: def Update(self, currentTimeMs): if self.publishInterval > 0 and currentTimeMs > self.nextPublishMe: - self.Publish(ClientMsg(self.network_id)) + self.Publish(ParticipantMsg(self.network_id)) print(f'Publish ClientMsg {self.network_id}') self.nextPublishMe = currentTimeMs + self.publishInterval @@ -114,8 +116,8 @@ class Participant: msgId = data[0] # print(f'msg {msgId} ') match msgId: - case ClientMsg.id: - self.ProcessClientMsg(remote_participant, ClientMsg(data)) + case ParticipantMsg.id: + self.ProcessClientMsg(remote_participant, ParticipantMsg(data)) case NetworkIdMsg.id: self.ProcessNetworkIdMsg(remote_participant, NetworkIdMsg(data)) # case InvestigateMsg.id: @@ -130,7 +132,7 @@ class Participant: # msg = Messages.BinaryMsg(data) # msg.thing.ProcessBinary(msg.data) - def ProcessClientMsg(self, sender, msg: ClientMsg): + def ProcessClientMsg(self, sender, msg: ParticipantMsg): pass def ProcessNetworkIdMsg(self, sender, msg: NetworkIdMsg): diff --git a/SiteServer.py b/SiteServer.py index 3635347..d7ed3c1 100644 --- a/SiteServer.py +++ b/SiteServer.py @@ -1,6 +1,6 @@ from Participant import Participant -from ClientMsg import ClientMsg -from NetworkIdMsg import NetworkIdMsg +from Messages.ParticipantMsg import ParticipantMsg +from Messages.NetworkIdMsg import NetworkIdMsg import socket import threading diff --git a/Thing.py b/Thing.py index 69a0a51..18bbd47 100644 --- a/Thing.py +++ b/Thing.py @@ -1,10 +1,11 @@ -from Spherical import Spherical -from Quaternion import Quaternion +from LinearAlgebra.Spherical import Spherical +from LinearAlgebra.Quaternion import Quaternion ## A thing is the basic building block # ## A thing is the basic building block class Thing: + """ A thing is the basic building block""" class Type: Undetermined = 0x00 Switch = 0x01 diff --git a/__init__.py b/__init__.py index b2489e2..9a95376 100644 --- a/__init__.py +++ b/__init__.py @@ -6,9 +6,9 @@ __all__ = ['Direction', 'SiteServer', 'SwingTwist'] -from .Direction import Direction +from .LinearAlgebra.Direction import Direction from .Participant import Participant from .Thing import Thing -from .Spherical import Spherical -from .SwingTwist import SwingTwist +from .LinearAlgebra.Spherical import Spherical +from .LinearAlgebra.SwingTwist import SwingTwist from .SiteServer import SiteServer \ No newline at end of file