From db16f95a4591620342819ba31e677fcb4f45c290 Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Sun, 23 Feb 2025 14:07:57 +0100 Subject: [PATCH] Refactorig and initial documentation (e.g. ParticipantMsg.py) --- .DS_Store | Bin 0 -> 6148 bytes DoxyGen/DoxyWarnLogfile.txt | 90 ++++++++++-------- Direction.py => LinearAlgebra/Direction.py | 0 Quaternion.py => LinearAlgebra/Quaternion.py | 0 Spherical.py => LinearAlgebra/Spherical.py | 2 +- SwingTwist.py => LinearAlgebra/SwingTwist.py | 8 +- .../__pycache__/Direction.cpython-312.pyc | Bin 0 -> 3105 bytes .../__pycache__/Quaternion.cpython-312.pyc | Bin 0 -> 1944 bytes .../__pycache__/Spherical.cpython-312.pyc | Bin 0 -> 3064 bytes .../__pycache__/SwingTwist.cpython-312.pyc | Bin 0 -> 1459 bytes .../LowLevelMessages.py | 2 +- Messages.py => Messages/Messages.py | 2 +- ModelUrlMsg.py => Messages/ModelUrlMsg.py | 2 +- NameMsg.py => Messages/NameMsg.py | 2 +- NetworkIdMsg.py => Messages/NetworkIdMsg.py | 2 +- ClientMsg.py => Messages/ParticipantMsg.py | 44 +++++---- ThingMsg.py => Messages/ThingMsg.py | 2 +- .../__pycache__/ClientMsg.cpython-312.pyc | Bin 0 -> 1171 bytes .../LowLevelMessages.cpython-312.pyc | Bin 0 -> 2885 bytes Messages/__pycache__/Messages.cpython-312.pyc | Bin 0 -> 4633 bytes .../__pycache__/ModelUrlMsg.cpython-312.pyc | Bin 0 -> 1862 bytes Messages/__pycache__/NameMsg.cpython-312.pyc | Bin 0 -> 1818 bytes .../__pycache__/NetworkIdMsg.cpython-312.pyc | Bin 0 -> 1178 bytes .../ParticipantMsg.cpython-312.pyc | Bin 0 -> 1830 bytes Messages/__pycache__/ThingMsg.cpython-312.pyc | Bin 0 -> 1578 bytes Participant.py | 26 ++--- SiteServer.py | 4 +- Thing.py | 5 +- __init__.py | 6 +- 29 files changed, 109 insertions(+), 88 deletions(-) create mode 100644 .DS_Store rename Direction.py => LinearAlgebra/Direction.py (100%) rename Quaternion.py => LinearAlgebra/Quaternion.py (100%) rename Spherical.py => LinearAlgebra/Spherical.py (96%) rename SwingTwist.py => LinearAlgebra/SwingTwist.py (62%) create mode 100644 LinearAlgebra/__pycache__/Direction.cpython-312.pyc create mode 100644 LinearAlgebra/__pycache__/Quaternion.cpython-312.pyc create mode 100644 LinearAlgebra/__pycache__/Spherical.cpython-312.pyc create mode 100644 LinearAlgebra/__pycache__/SwingTwist.cpython-312.pyc rename LowLevelMessages.py => Messages/LowLevelMessages.py (96%) rename Messages.py => Messages/Messages.py (97%) rename ModelUrlMsg.py => Messages/ModelUrlMsg.py (96%) rename NameMsg.py => Messages/NameMsg.py (96%) rename NetworkIdMsg.py => Messages/NetworkIdMsg.py (97%) rename ClientMsg.py => Messages/ParticipantMsg.py (58%) rename ThingMsg.py => Messages/ThingMsg.py (96%) create mode 100644 Messages/__pycache__/ClientMsg.cpython-312.pyc create mode 100644 Messages/__pycache__/LowLevelMessages.cpython-312.pyc create mode 100644 Messages/__pycache__/Messages.cpython-312.pyc create mode 100644 Messages/__pycache__/ModelUrlMsg.cpython-312.pyc create mode 100644 Messages/__pycache__/NameMsg.cpython-312.pyc create mode 100644 Messages/__pycache__/NetworkIdMsg.cpython-312.pyc create mode 100644 Messages/__pycache__/ParticipantMsg.cpython-312.pyc create mode 100644 Messages/__pycache__/ThingMsg.cpython-312.pyc diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..b92d56a18ae13c47b054eaacf8db0e466265ab19 GIT binary patch literal 6148 zcmeHKJ5B>Z41I=3L`svAa<0G)M$w`ifD51ys3NvNNYHJ?xi}inA0fg9IvVsW*>A>U zdo-_DuL0QRd4C100W7JGcylusKX;wUS$P~SYHV?j$NkgYVK>gAPdhyK0s}_8;1yr; z#{)}#KYC#8-IzzG>&Yty#DEwO17bi7{LX+kSjuvhC@TiUfEf5>z`qZT>evgX#Q1d3 z#0WrK&>g~c%o4=r4q`8y66v8>rV=yNYQ(Tir@vKPFPsuH9TqpUPTg!Zp;+8be~WNf zPm~n{V&Is8^W3hz|6fyonE#KHv=akj;9oIdi{WP2@JZEMXOHt<+o-oxk9nuMa2+W$ m(T<7Hj=Ax6d>KI**L= 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 0000000000000000000000000000000000000000..cfa819da319c2c98bb4383e11186560f40efca3f GIT binary patch literal 3105 zcmcImO>7fK6rQnn6FYI@+984f0S8dQ0^w2;f>Z)D2?{@n+laOYAG+FjHi?7n4YTWj ztstT*l>oH@i9?L4iuBUPLKWczJvBYGQZKgL18ljKL%Frdp%NGR-mcewgtR?$4&ToE znb~=7zIii0x3n}7Xy5*>O?)g8@*4_v6H1-6pP;iq7-2L{BE&(42y@I6=Dg>yJR;OV z6bg1?YZNM#Yy|wlCe+xR_Ag4~#Hw-jU#)S3HB{MPg;q1iHPp=6P-7EoY>l=pO@ock zQ3ywE6@Kltt_^~)Kok;zXd({Q%;-FgI5FCYz?^_0695~S2-wIP09~vR(9K+cP0S70 zoNfww4EJD+D^WeBCZpwWOTR*SEnxm?md+9hdRCitfJAL6O>#7xa~MsNDvxEX zJ=cWKypOj8t_h#FtbvY1?WCfB8)rs61Dyq;mt&kIQ`LUx3vHH8m1$sU5Hn~YQ{|1W zSim3CP}k7kCeL}oaa>O1II)>DgI+fCX3%ub!SNUvqN-0q=5R%U0B=TBqa?|UK>~c$ z2{2Xo%e5fD9C_;9lHGK7=bfEPJ@p?^+AQf{BL$U1N?vh*4gt}inhAN z2A!2%G`G;+z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z0FHFf-Q(4f7*gsXLMw($I6{|wG*&Z=eKcZE#*o9ZS4rA{j zv-W7XqVSfk%1+ivvE6bKzRoyFe;i@Dg>Xk!&VH(&~RgDwFt{^`ie zu8A+v9Q-VHiB+}&Y$C$SkD$Pn76ZTiQDM{@nb#L@f2nGoP*v?EkGG7P$5-kWWfQ0P z3IJv0l&zk!N2ZV)2zY!`ed38LhFw|m1pEO^FU7P{f2>pGwkIQ{(icGbzChZq4e>dK z?~ky8zDN>VhWISQ$9;y5`4ZKwhG|$Ja>mVbWP zm5wK8U%YeYaPrRY^5Nt{zjw})3!f5KdX{Ma@2E2ga#L=G%D8)_g2bM?np)Kr#Y-wm zwXWe_qn%ci9~!C|WN4NhL)x-c+o)7^d`&evi=kh^XYo%dxRC5tvd_w+T8DoGL7X^C zgEW55<;AHEA6h{jLl#6jj)TXo7<3E`pT|oW8b05K-K5u9jLp^W@;Y%pnBs@@CdSws zXWc?|#uGyRf>b*t|2(%b_sheLdpmC(Ca5`l|vJ~!8rf5L=M`5)J1 Bt>*v$ literal 0 HcmV?d00001 diff --git a/LinearAlgebra/__pycache__/Spherical.cpython-312.pyc b/LinearAlgebra/__pycache__/Spherical.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..44b9330038676aea6bb5018710f30b4215499e4d GIT binary patch literal 3064 zcmd5;O>7fK6rR~1{{$yaC@!Jp#|eRCDZ~({sv-y_jZ_dNDh<6jh}C9yLpHL#VRjSn z%BeU|$w;k0y%5w^Nlw_xC7cTCp{i7=t$L^}w=&wMr=GaA$)OdezS&*do5%<*RXftY znR)Z}&71eW_hx=g27#+AO)vTlJ-mrrs<)c6fApQYD%!rDWEpm)cC{ z>v14=Q4Z&j2qU-U7?{;IMp;zEBLZWG6wNTDjI7#WrDm$Y+MJ=LCI~$-2?H^x)_6Sr z^lah-LnTIHS~6hs#IP>Uq}7aRB!<=5#CutDQqLr0J!29*CF?{@ysKqYiJVSdQOAjt zs9W7XowY-vsAV)$6s@fdevL=HX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>qHxYuiF@o1)d!+s$Xz@YO(X)I{ltmdfutpW+y3{rt7?h9+c z8uuIhYQ497X9W#@TD^Utw>&7o{OO)_r}XUPdp+rg(h$Q!QeZS{GvA)n9)&V~Y0rN~ zuno~f_qy)I&>RmgT8~$gXa35Xfj8Lla=)_BGJTZC#Sce4y-8xSitnnce;xR|jcT+( z)x3WB{6~Rmsrh@;3XCV4$jfbyvaGcV3K$OHsOPZER^VXDh!xYk+P1urX38|3z&1_BE0f4;USLIR4sm)< zHjn66NF%2AV7x6U;bjOvLb3&aNnZ|xY5DYyI{@4s$wR&k=4H9O)BG23%K~uU6-`b~ z9h>LcP7KfcDn{UgEBsC;YlO|kr46}K79)Mf708e K{0|^W-Tnuv^GM$S literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..2e62506101aea05aa19bf85d30c76b449a719aab GIT binary patch literal 1171 zcmaJ=&rj1(9DlD}N9nr30*H#k8DUyccJ*L9=+tNeBOxZHm!_<5qqFPay-rgylbLXs z2O|fQ$qf?{CHx8g30_7*!qR9$BA4BW!wV3g zULRrS(VC!24IrRG1E`zv#fWfPR5m*Ik&=4s0xx5neB6B)+%#69D+s+KhH8*H# zlcO-3Vc3-bRoEo0JcSx?x~)JNI=#5`d3+QiZA4Dxu>c09>O&g&w6shNf+EVvFL3g-m~va(pFDTK9;$B$FV=LBJr zT+&HKx00!1rc^+-Ly{@ArB%` zEt&w%XL^%*YLwr%av3nz&q@Wlu*=&U?qmyjwyQI8euW%YrpNJ5W^Xem>0{vk{&}_| z%(zwpZQe0EY>%T$30la`Ig1L9Bg`Z%l(JcbHH@-e(ANn&sdzk&2UtM=Ji?}KnJZ}J z;u(^Ao-rCo(iAG75gMt7VjII>u718+zjn7VG`xQ$v9Y{9Qw<)-m-pn@jvQ;qgCElG z(uV>+B~^pf<&Wcg(Zo(PQ5SCT_61&#i2q5UU>E|)xW)%;z^M|~TW7NSu6~ZPv7%g5Pom}ymo9SCTY^rf>RU_rloG13bmzFN>v3FLLf~!5LHx;cjIj8>?Uv5 zPHZ`=-y{=) zA^;Z^QI)1RMY<_WxD*$R$chZyouVOk610*ipN5~S_9HZahD1R09SJ(UM`q~)ksUqwHPfNT-p>fFZ)Io?Mrs1Tk z_3@e3UDPcVNpY>#PhazsAsHTT0sSs=iyZn^q%^D><)a*GQY0jgR(}FXn+Dg~$kx^t zLmyQF-72nT^OIUE#MvS<61rl`mT_e=WvOOJu%*ew)Rf9>Nn55{mKi>;Cc~ektZ73JM-AO#Mm%aTHT;oknvs}l zhDVHr5jCmC8v{q?QhpJCvNbhqpL7@ z>o6(?o>2_kI=mqfPgjBF_hrwm2YQR*3V)|##Vqx`RSq0l3!EqgPW(9bP%H<|KAbNF zhO)!C!UX>Y{J5DlgR4?2mj$zFjG95p`&mL(N;XB{Gc*YZq$rnsl<4`$!5_c7IA6NV-Ic`Y!GE^TQj#U(tHD}|ADfw13#e^KMPQ= zQATL2G)_Wd4O7+)I_5&Q2UtjCy(r`6*d;0O3&HSn0jb-9Pp~xO<@FdpkS44&Z8ettbJwYyN?f zf8d9U_a^R6l>J8m>+PJoabX>jy6@K6KZJb_de6(gmKq8OX1I2Etk$!a604bYfGS$I z$+Hty*;lmt_QnRvQpn)xuz#^H-aOyd5BW^u?)yD;l;~)^%`ucngzys zP{N8Al5LM>YI;5FFnDb5C1WfRu~epGo^faTcx%cJ?xviCraVsWoM z)E-}Me%Z{Mh4Fl5tw}^QN*alB2{foTxHwixx+_d{iuS~l)dPMs2in>Xl QdE)2k=}k`$?RK2~3r{*yIsgCw literal 0 HcmV?d00001 diff --git a/Messages/__pycache__/Messages.cpython-312.pyc b/Messages/__pycache__/Messages.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a970eee0b05be4123ac699199cc032fce9c6561f GIT binary patch literal 4633 zcmc&%-A^0Y6`vW8&EOehzDW#A9l%+fRL~_P1iI~N(=;Cx2r1cppi(Ty9*l{x$(?bw zc1@K?c`#KfHc};sTD4xO(h}vN$XL@ zSx&0T@J0FV@N7n1OeKdSsiaC$iAajb!{$qs%3x?Eqc_gUBpy!0vvRi8a%-p}!*D2w z{5_`ZZQh3g6ER`MF?E%?y9kpFCdVw(E^KjL4z~{)7=I} zbB7>mFm1BU6^u+t8`vqMzyPF<;~O_0-7Ng76d2P2W5t2>7Dj`b zcW}$M;~gyuqZFf=V1q7%Ldo#5917{~P-r<7O($?Hg+h1I;e`2wi${%kx1ztD$QqC# z&NPq&Hx6ZZdKA=nz?2(3_b$A2v(A>6F5Y=&U*er-4HML^f0BLh#D0>kbDZIWPQB@B z@~*6?@mN@ur+os`v2Qsj0h9@PaEGZ2iPa7N&8_baGqZD+tTo{X!ZP`0bq%^~Z-J7{tY7{tuy zFSI-k=J|)-^0D5{JC7Ul{O>(xTwJ6Jln81P^pYSjx+@_kW9lLapu`q|9+V+Nb)^NE z8G*8=>E5M%o^$pY;G<4`@cr=QDDbP2Xv1tuq1fZb-Nk@M5NnGn*!w{OnTf4Ior765 z-t0_}BYmK$J1M+yUg)7f5y9xyBnf}UfOPvQ=lAdr8$8n05S*yBmYS&kaU{=6_vKMwz5h$AF>k|g{sDemerR~R=f9wc4voCTTw9rzY1B2 z>+<~O5=riGE6eq+dPM5YKj+b7h1gj3>UU8OJzw>l_{-JDR}0b4Q=g?^$F4qK-Rb!`GzRW+yKnQo z&5=(hp*?6cg7zUSRMWv!VEzw0feSCzO}1V&zt88``*4SXzJOD$P%}#vXu#YgfYTaQ z{llttbYoaG>vR-RN6yjBKt@|CzV23?J zgLR4K;u}`XegZ}`1skc$0evXJt{~{7w-+N%BaZYm>Ec2ZOD z^_8WT^($*v_8Ry>cU~+BK25*?e_Rv>_S{U@JAYCNqkqh3or7>?eD7>U<6Pl%Q5Y%< zZ6%>s6M8p)^FlaX_O`t-QDBbH8*gP)s0SpRA@nk2OBWOJ{yX7);|BLrav986^Z{?t zdk&Umzh*|iX1ZSUZS2`^8DOtZx!AsM8DOuPd)SWr;wuLJUccYPw!dV6Q3wAE9K=u! literal 0 HcmV?d00001 diff --git a/Messages/__pycache__/ModelUrlMsg.cpython-312.pyc b/Messages/__pycache__/ModelUrlMsg.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ae566111379335f12a3631a1864127ac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^+Rz>R#mP?%n;!XSKw4w-1L$?et)OBN#QK@4XP73+wEYfH^esY;tRIo&DZ( z%%Prl*_|K`r@2In>(Fi zOuO7#WHgWKH`_<}m}j zwi&LFZ%yd~5#yD9lH$Ez$z~-*RHUrMJG$j}%CKnD-$$g_`Z9dkO0n27R2~3;|FD!W z!Sc*VN-vWNDm=ay9{-_hKm1|Me-OH~`N4i@yyiOyy;YYt<=aNTM5a|IZW$U~`;>px~F UiuxOkov`E7U~Tqa1e;y;A9j3t=>Px# literal 0 HcmV?d00001 diff --git a/Messages/__pycache__/NetworkIdMsg.cpython-312.pyc b/Messages/__pycache__/NetworkIdMsg.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5d3f63362f8f0603b9b79734388bc21e17d8934b GIT binary patch literal 1178 zcmaJ=%}*0S6rb6Tx@=oY!s zhmvUEV1nE*;h^D9@K5jphJbq@2WEi5tpS5aaF6%HG_E8lVx1in=t{G5h>&y+ zWqhxXuz6@qP-P1spg{v@oB=i7;55PDHPH~(fEF-BidRa!5^zIF^~n@hXnhrvW`>_&C^ZR$8Y_+H+9co@D(4IiW1d1gH2 zLHDf&%>)1De}{UuC^JheZr41*X4*1W z(ds}4%WeA*4I_^!P@030jj8pi{b0P-+jlaO*jd@0s|J3Au5P5(Q?*bJ`<#lrB3A>| zm3JdY(TRiT#J+U>OaeV4N0InJB)%`jag-KQBsO0=okzOv%DSE}7)6WeAzfc7rY+xt zdub@{W58An_b?cw@CkTTyf=7{_kdAJhAFIpT35L8pcd|~JUWT?SDyToMe%lHpi3P0 z^B7-Ag?FQ^?VD^Vn9<{xWR)(iIhXGFP2R_&)WQA|!a6(UA%x#R;!GZe Fegnlk`27F? literal 0 HcmV?d00001 diff --git a/Messages/__pycache__/ParticipantMsg.cpython-312.pyc b/Messages/__pycache__/ParticipantMsg.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..60a3e4c2c043481085b082d577ae381727e9d174 GIT binary patch literal 1830 zcmZux&2Jk;6rcUD<817FtAWrY6E!uMRxuJ1;!q)=0TiS-MWq7yvfAv9<4M=M$;>#> zT1GNzDwzW!2c*zj5Rm}&PvB4Bl88!)Rz->gmvAz2x%9-FUEBFk=J58tdGGz^eeUm> zjDg^65C67$y&s{!q|iNy4%5y8vx^+$C@!ifMMXg>`UE-ZHgYtgJk?^mq8jMA#Hkc= zN|;()BAi>R#E!Kw?U*r zOxSrFxGG^PI9_Lj6VE2|hJoRHQ6?T{#3po;ICv$%7GPZRy$z1owmiH-aLIRFf2(7P z3q)-B?BSvVVMTDl2LR8n!UI^8Epa{s3`$X^9NR7>p1{0nmt&(2{F+Zah>vbsg1AA1 zce)293svfzs**{%#9I~RLTGsL%O-Vfsp%da7}<>W8jxKil&+$#h@Rck4#!e;rH;(r zeV|^jPj-EK_5*drQC@}Xi(Y}6(`t`r@m)qBa%^FbY;}7A1!EWr?ocnTkSzN9&^)UG zW>NJZ2mE=NbVa=HssIGjSt|Qs}%cr3P zO1FJqsb|BmCP(Jdxf)?rt*g$tFl$eH_V=p6DD`uixS)_$7B_X(qxOKWmVNN-l4 zPq07GcR59jS;0K+b+$7zE7ekoFq4r|G&8X%Hw&8AL6j(GZj6X3^CIJTdE}4a;-irm zBlY~49E+SDjR=!}Ox7m}{7X?zW3qptaTZIMjCn4155|y7$YC;Yju%^*W5w@buBp+~LsNL28bT0cvhQPNQd4h-rp~X;yrv>PkLsnj2Ni z?P&T;)A4Q7jFTLc!4H|H{F4bwP~YRAlBvh#7?s=vkY7>sNR(|{Bv~n01O5(>$LL>G zPo!FDG&I)uu&F&NoQ#e&K5pK9w0v@HvhnGT_J=;%()$v(_ug(J__RkeiJLK`1S;gT zaHP9u^Ie8X{P?vg$;mXM2wtY{#Ob}qX5dc#3HUgWmZm7mpD6o6zoFdR`SL#mpUCTf DeSFOp literal 0 HcmV?d00001 diff --git a/Messages/__pycache__/ThingMsg.cpython-312.pyc b/Messages/__pycache__/ThingMsg.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..bd7b968a4663eebe9a92aab5555356468661484e GIT binary patch literal 1578 zcmaJ>&1)M+6rWk`%4>aCQY?d;y4FXr%K8wI(pyUdt=lvWk_%}m=(4P}V_Ax{vS-(A z*Qi7RA0%k83n{|TgM2b2e?tF+UUVpBSz0ip7u^g>EXkVEh^Rt@0{B$P3)~Lz;k54nU9SM5lGqpe0I)K<*P=I3{|4(dS@?qa@g(A`KBL z)Ri9;m}zPiRz|`f!UT-o1<)gml&B7dIxPisp(N^ok_0mda{;ET2X*n7mKJsCn3O_x zKv{6*FZZfOrC?TuZE!KfZ!DH4UjUd85hm_OS0H-CqOf?QMJ+!(c|Jj0X;GcN0p~5E zPEUaoCfw9BaDfSj5xfDMIN|(S5u3E=e|!l~-)jlAh;MVVg4T_9p|*5$;v>+wi6zv$ zoAS@bD`?C_wuvGYhnVmXa~Y!hA$m|`H&ivNhG}U=nYq%AZ86gg8O-{&$sem#-IXmY zE27XCS@u427xy*J3=3%irii2xa7B~VcU@7}EX|cXbrVCS)9LGv^Iw^aoB4gsENk`r zRpz zF^D$#E4*^5|MJNn;jFWs?cY7CbhdujcGlAU#Mym-g<1BkOh0q>b!Y3x;^lhQ(~Bhs zv9y!kxRB4~Q}J2U$-Z;3dAx(95_d7kI{1y-KxVNT;zq!zronb>n0^iA^r z=Z}aY6geiSEbtgCJdOfu!gXv$-VBqK{(sjFB<2KLGFELIeEF3>mQsII>CP; z$&-iOhfXAZvfbUrrO++R?26suRXDg2>I6Fn&sKY>pHc%k^KyyAS5KaFpA6)6ejCCl zw5Wu!D-Er|RMicsYNM$i))7Zk_25vek59&FuYt)-J*HLQ_}x4O;#cDN^>Q88%Wo)i z6ONCGvlwlER;zQMD_px literal 0 HcmV?d00001 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