Completed client/nw_id test

This commit is contained in:
Pascal Serrarens 2024-12-31 13:09:36 +01:00
parent cfe0840863
commit 637a0935b0
18 changed files with 3386 additions and 194 deletions

11
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,11 @@
{
"python.testing.unittestArgs": [
"-v",
"-s",
"./test",
"-p",
"*_test.py"
],
"python.testing.pytestEnabled": false,
"python.testing.unittestEnabled": true
}

67
ClientMsg.py Normal file
View File

@ -0,0 +1,67 @@
from 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
## 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):
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):
if buffer_ref is None or self.network_id is None:
return 0
buffer: bytearray = buffer_ref[0]
buffer[0:ClientMsg.length] = [
ClientMsg.id,
self.network_id
]
return ClientMsg.length
# @staticmethod
# def Serialized(buffer_ref, network_id):
# if buffer_ref is None or network_id is None:
# return 0
# buffer: bytearray = buffer_ref[0]
# buffer[0:ClientMsg.length] = [
# ClientMsg.id,
# network_id
# ]
# return ClientMsg.length
## Send the network_id to the participant
# def SendTo(participant, network_id):
# if participant is None or network_id is None:
# return False
# participant.buffer[0:2] = [
# ClientMsg.id,
# network_id
# ]
# participant.SendBuffer(ClientMsg.length)
## Publish the network_id
# def Publish(participant, network_id):
# if participant is None or network_id is None:
# return False
# participant.buffer[0:2] = [
# ClientMsg.id,
# network_id
# ]
# participant.PublishBuffer(ClientMsg.length)

View File

@ -0,0 +1,39 @@
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.

2861
DoxyGen/Doxyfile Normal file

File diff suppressed because it is too large Load Diff

226
DoxyGen/DoxygenLayout.xml Normal file
View File

@ -0,0 +1,226 @@
<doxygenlayout version="1.0">
<!-- Generated by doxygen 1.8.18 -->
<!-- Navigation index tabs for HTML output -->
<navindex>
<tab type="mainpage" visible="yes" title=""/>
<tab type="pages" visible="yes" title="" intro=""/>
<tab type="modules" visible="yes" title="" intro=""/>
<tab type="namespaces" visible="yes" title="">
<tab type="namespacelist" visible="yes" title="" intro=""/>
<tab type="namespacemembers" visible="yes" title="" intro=""/>
</tab>
<tab type="interfaces" visible="yes" title="">
<tab type="interfacelist" visible="yes" title="" intro=""/>
<tab type="interfaceindex" visible="$ALPHABETICAL_INDEX" title=""/>
<tab type="interfacehierarchy" visible="yes" title="" intro=""/>
</tab>
<tab type="classes" visible="yes" title="">
<tab type="classlist" visible="yes" title="" intro=""/>
<tab type="classindex" visible="$ALPHABETICAL_INDEX" title=""/>
<tab type="hierarchy" visible="yes" title="" intro=""/>
<tab type="classmembers" visible="yes" title="" intro=""/>
</tab>
<tab type="structs" visible="yes" title="">
<tab type="structlist" visible="yes" title="" intro=""/>
<tab type="structindex" visible="$ALPHABETICAL_INDEX" title=""/>
</tab>
<tab type="exceptions" visible="yes" title="">
<tab type="exceptionlist" visible="yes" title="" intro=""/>
<tab type="exceptionindex" visible="$ALPHABETICAL_INDEX" title=""/>
<tab type="exceptionhierarchy" visible="yes" title="" intro=""/>
</tab>
<tab type="files" visible="yes" title="">
<tab type="filelist" visible="yes" title="" intro=""/>
<tab type="globals" visible="yes" title="" intro=""/>
</tab>
<tab type="examples" visible="yes" title="" intro=""/>
</navindex>
<!-- Layout definition for a class page -->
<class>
<briefdescription visible="no"/>
<detaileddescription title=""/>
<includes visible="$SHOW_INCLUDE_FILES"/>
<inheritancegraph visible="$CLASS_GRAPH"/>
<collaborationgraph visible="$COLLABORATION_GRAPH"/>
<memberdecl>
<nestedclasses visible="yes" title=""/>
<publictypes title=""/>
<services title=""/>
<interfaces title=""/>
<publicslots title=""/>
<signals title=""/>
<publicmethods title=""/>
<publicstaticmethods title=""/>
<publicattributes title=""/>
<publicstaticattributes title=""/>
<protectedtypes title=""/>
<protectedslots title=""/>
<protectedmethods title=""/>
<protectedstaticmethods title=""/>
<protectedattributes title=""/>
<protectedstaticattributes title=""/>
<packagetypes title=""/>
<packagemethods title=""/>
<packagestaticmethods title=""/>
<packageattributes title=""/>
<packagestaticattributes title=""/>
<properties title=""/>
<events title=""/>
<privatetypes title=""/>
<privateslots title=""/>
<privatemethods title=""/>
<privatestaticmethods title=""/>
<privateattributes title=""/>
<privatestaticattributes title=""/>
<friends title=""/>
<related title="" subtitle=""/>
<membergroups visible="yes"/>
</memberdecl>
<memberdef>
<inlineclasses title=""/>
<typedefs title=""/>
<enums title=""/>
<services title=""/>
<interfaces title=""/>
<constructors title=""/>
<functions title=""/>
<related title=""/>
<variables title=""/>
<properties title=""/>
<events title=""/>
</memberdef>
<allmemberslink visible="yes"/>
<usedfiles visible="$SHOW_USED_FILES"/>
<authorsection visible="yes"/>
</class>
<!-- Layout definition for a namespace page -->
<namespace>
<briefdescription visible="yes"/>
<memberdecl>
<nestednamespaces visible="yes" title=""/>
<constantgroups visible="yes" title=""/>
<interfaces visible="yes" title=""/>
<classes visible="yes" title=""/>
<structs visible="yes" title=""/>
<exceptions visible="yes" title=""/>
<typedefs title=""/>
<sequences title=""/>
<dictionaries title=""/>
<enums title=""/>
<functions title=""/>
<variables title=""/>
<membergroups visible="yes"/>
</memberdecl>
<detaileddescription title=""/>
<memberdef>
<inlineclasses title=""/>
<typedefs title=""/>
<sequences title=""/>
<dictionaries title=""/>
<enums title=""/>
<functions title=""/>
<variables title=""/>
</memberdef>
<authorsection visible="yes"/>
</namespace>
<!-- Layout definition for a file page -->
<file>
<briefdescription visible="yes"/>
<includes visible="$SHOW_INCLUDE_FILES"/>
<includegraph visible="$INCLUDE_GRAPH"/>
<includedbygraph visible="$INCLUDED_BY_GRAPH"/>
<sourcelink visible="yes"/>
<memberdecl>
<interfaces visible="yes" title=""/>
<classes visible="yes" title=""/>
<structs visible="yes" title=""/>
<exceptions visible="yes" title=""/>
<namespaces visible="yes" title=""/>
<constantgroups visible="yes" title=""/>
<defines title=""/>
<typedefs title=""/>
<sequences title=""/>
<dictionaries title=""/>
<enums title=""/>
<functions title=""/>
<variables title=""/>
<membergroups visible="yes"/>
</memberdecl>
<detaileddescription title=""/>
<memberdef>
<inlineclasses title=""/>
<defines title=""/>
<typedefs title=""/>
<sequences title=""/>
<dictionaries title=""/>
<enums title=""/>
<functions title=""/>
<variables title=""/>
</memberdef>
<authorsection/>
</file>
<!-- Layout definition for a group page -->
<group>
<briefdescription visible="yes"/>
<groupgraph visible="$GROUP_GRAPHS"/>
<memberdecl>
<nestedgroups visible="yes" title=""/>
<dirs visible="yes" title=""/>
<files visible="yes" title=""/>
<namespaces visible="yes" title=""/>
<classes visible="yes" title=""/>
<defines title=""/>
<typedefs title=""/>
<sequences title=""/>
<dictionaries title=""/>
<enums title=""/>
<enumvalues title=""/>
<functions title=""/>
<variables title=""/>
<signals title=""/>
<publicslots title=""/>
<protectedslots title=""/>
<privateslots title=""/>
<events title=""/>
<properties title=""/>
<friends title=""/>
<membergroups visible="yes"/>
</memberdecl>
<detaileddescription title=""/>
<memberdef>
<pagedocs/>
<inlineclasses title=""/>
<defines title=""/>
<typedefs title=""/>
<sequences title=""/>
<dictionaries title=""/>
<enums title=""/>
<enumvalues title=""/>
<functions title=""/>
<variables title=""/>
<signals title=""/>
<publicslots title=""/>
<protectedslots title=""/>
<privateslots title=""/>
<events title=""/>
<properties title=""/>
<friends title=""/>
</memberdef>
<authorsection visible="yes"/>
</group>
<!-- Layout definition for a directory page -->
<directory>
<briefdescription visible="yes"/>
<directorygraph visible="yes"/>
<memberdecl>
<dirs visible="yes"/>
<files visible="yes"/>
</memberdecl>
<detaileddescription title=""/>
</directory>
</doxygenlayout>

View File

@ -0,0 +1,12 @@
/* Custom PasserVR CSS for DoxyGen */
a {
color: #e77505;
}
.contents a:visited {
color: #e77505;
}
a:hover {
color: #10659C;
}

View File

@ -1,5 +1,5 @@
import numpy as np
from .SwingTwist import SwingTwist
from SwingTwist import SwingTwist
def SendAngle8(buffer, ix_ref, angle):
# Normalize angle

View File

@ -1,10 +1,12 @@
# from .Participant import Participant
from . import LowLevelMessages
from .Thing import Thing
import LowLevelMessages
from Thing import Thing
class IMessage:
id = 0x00
## Serialize the message into the given buffer
#
## @returns: the length of the message
def Serialize(buffer):
return 0
@ -20,60 +22,6 @@ class IMessage:
return False
return participant.PublishBuffer(bufferSize)
class ClientMsg(IMessage):
id = 0xA0
length = 2
def __init__(self, network_id):
if isinstance(network_id, int):
self.network_id = network_id
elif isinstance(network_id, bytes):
self.network_id = network_id[1]
def Serialize(self, buffer_ref):
if self.network_id is None:
return 0
buffer: bytearray = buffer_ref[0]
buffer[0:ClientMsg.length] = [
ClientMsg.id,
self.network_id
]
return ClientMsg.length
class NetworkIdMsg(IMessage):
id = 0xA1
length = 2
def __init__(self, network_id):
# self.network_id = None
# if isinstance(network_id, int):
# self.network_id = network_id
# elif isinstance(network_id, bytes):
self.network_id = network_id[1]
# def Serialize(self, buffer_ref):
# if self.network_id is None:
# return 0
# buffer: bytearray = buffer_ref[0]
# buffer[0:NetworkIdMsg.length] = [
# NetworkIdMsg.id,
# self.network_id
# ]
# return NetworkIdMsg.length
def SendTo(participant, network_id):
if network_id is None:
return 0
participant.buffer[0:2] = [
NetworkIdMsg.id,
network_id
]
return NetworkIdMsg.length
class InvestigateMsg():
id = 0x81
length = 3

44
NetworkIdMsg.py Normal file
View File

@ -0,0 +1,44 @@
from Messages import IMessage
## A network id message invites another participant to a site
#
## This can be sent in response to a ClientMsg
class NetworkIdMsg(IMessage):
id = 0xA1
length = 2
## Create a network id message
#
# @param network_id The network id assigned to the remote participant.
def __init__(self, network_id):
self.network_id = None
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):
if self.network_id is None:
return 0
buffer: bytearray = buffer_ref[0]
buffer[0:NetworkIdMsg.length] = [
NetworkIdMsg.id,
self.network_id
]
return NetworkIdMsg.length
# def SendTo(participant, network_id):
# if network_id is None:
# return 0
# participant.buffer[0:2] = [
# NetworkIdMsg.id,
# network_id
# ]
# return NetworkIdMsg.length

View File

@ -1,69 +1,101 @@
import socket
from . import Messages
from .Thing import Thing
import Messages
import threading
from ClientMsg import ClientMsg
from NetworkIdMsg import NetworkIdMsg
from Thing import Thing
## A participant is device which can communicate with other participants
#
## Currently only UDP communication is supported
class Participant:
publishInterval = 3 # 3 seconds
def __init__(self, ipAddress, port):
publishInterval = 3000 # 3 seconds
def __init__(self, ipAddress = "0.0.0.0", port=7681, remote=False):
self.buffer = bytearray(256)
self.ipAddress = ipAddress
self.port = port
self.udpSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.udpSocket.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
# self.udpSocket.bind(("0.0.0.0", 7681))
self.udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.udp_socket.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
self.buffer = bytearray(256)
self.network_id = 0
self.nextPublishMe = 0
if remote == False:
self.udp_socket.bind(("0.0.0.0", 7681))
self.network_id = 0
self.nextPublishMe = 0
self.others = []
self.thread = threading.Thread(target = self.Receiver)
self.thread.daemon = True
self.thread.start()
def SendBuffer(self, bufferSize):
if self.ipAddress is None:
return False
if bufferSize <= 0:
def GetParticipant(self, ip_address, port):
found_participants = (item for item in self.others
if item.ipAddress == ip_address and item.port == port)
participant = next(found_participants, None)
return participant
def AddParticipant(self, ip_address, port):
remote_participant = Participant(ip_address, port, remote=True)
self.others.append(remote_participant)
remote_participant.network_id = len(self.others)
return remote_participant
def Send(self, msg):
buffer_size = msg.Serialize([self.buffer])
if buffer_size <= 0:
return True
self.udpSocket.sendto(self.buffer[:bufferSize], (self.ipAddress, self.port))
self.udp_socket.sendto(self.buffer[:buffer_size], (self.ipAddress, self.port))
return True
def PublishBuffer(self, bufferSize):
if self.ipAddress is None:
return False
if bufferSize <= 0:
def Publish(self, msg):
buffer_size = msg.Serialize([self.buffer])
if buffer_size <= 0:
return True
self.udpSocket.sendto(self.buffer[:bufferSize], ('<broadcast>', self.port))
self.udp_socket.sendto(self.buffer[:buffer_size], ('<broadcast>', self.port))
return True
def PublishMe(self):
msg = Messages.ClientMsg(self.network_id)
msg.Publish(self)
def Update(self, currentTime):
if (currentTime > self.nextPublishMe):
self.PublishMe()
self.Publish(ClientMsg(self.network_id))
print(f'Sent ClientMsg')
self.nextPublishMe = currentTime + Participant.publishInterval
Thing.UpdateAll(currentTime)
def ProcessClientMsg(self, data: bytearray):
def ProcessClientMsg(self, msg: ClientMsg):
if msg.network_id == 0:
self.Send(NetworkIdMsg(self.network_id))
print(f'############################ New Client -> {self.network_id}')
else:
print(f'############################ New Client')
pass
def ProcessNetworkIdMsg(self, data: bytearray):
def ProcessNetworkIdMsg(self, msg: NetworkIdMsg):
self.network_id = msg.network_id
print(f'receive network id {msg.network_id}')
pass
def ProcessInvestigateMsg(self, data: bytearray):
pass
def Receiver(self):
while True:
data, addr = self.udp_socket.recvfrom(1024)
remote_participant = self.GetParticipant(addr[0], addr[1])
if remote_participant is None:
remote_participant = self.AddParticipant(addr[0], addr[1])
remote_participant.ReceiveData(data)
def ReceiveData(self, data):
msgId = data[0]
match msgId:
case Messages.ClientMsg.id:
msg = Messages.ClientMsg(data)
self.ProcessClientMsg(msg)
case Messages.NetworkIdMsg.id:
msg = Messages.NetworkIdMsg(data)
self.ProcessNetworkIdMsg(msg)
case ClientMsg.id:
self.ProcessClientMsg(ClientMsg(data))
case NetworkIdMsg.id:
self.ProcessNetworkIdMsg(NetworkIdMsg(data))
case Messages.InvestigateMsg.id:
msg = Messages.InvestigateMsg(data)
self.ProcessInvestigateMsg(msg)

View File

@ -1,93 +1,3 @@
# ControlCore_Python
\mainpage Control Core for Python
## Getting started
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
```
cd existing_repo
git remote add origin http://gitlab.passervr.com/passer/controlcore/controlcore_python.git
git branch -M main
git push -uf origin main
```
## Integrate with your tools
- [ ] [Set up project integrations](http://gitlab.passervr.com/passer/controlcore/controlcore_python/-/settings/integrations)
## Collaborate with your team
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Test and Deploy
Use the built-in continuous integration in GitLab.
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
Control Core contain generic functionality for controlling Things

View File

@ -7,14 +7,14 @@ import select
class SiteServer(Participant):
def __init__(self, ipAddress, port):
super().__init__(ipAddress, port)
self.udpSocket.setblocking(0)
self.udp_socket.setblocking(0)
def Update(self, currentTime):
ready_to_read, _, _ = select.select([self.udpSocket], [], [], 0.1) # Timeout of 0.1 seconds
ready_to_read, _, _ = select.select([self.udp_socket], [], [], 0.1) # Timeout of 0.1 seconds
while ready_to_read:
data, addr = self.udpSocket.recvfrom(1024)
data, addr = self.udp_socket.recvfrom(1024)
self.ReceiveData(data)
ready_to_read, _, _ = select.select([self.udpSocket], [], [], 0.1) # Timeout of 0.1 seconds
ready_to_read, _, _ = select.select([self.udp_socket], [], [], 0.1) # Timeout of 0.1 seconds
return super().Update(currentTime)

View File

@ -1,5 +1,5 @@
import math
from .Direction import Direction
from Direction import Direction
class Spherical:
def __init__(self, distance, direction):

View File

@ -1,5 +1,5 @@
from .Direction import Direction
from .Quaternion import Quaternion
from Direction import Direction
from Quaternion import Quaternion
class SwingTwist:
def __init__(self, swing: Direction, twist: float):

View File

@ -1,6 +1,9 @@
from .Spherical import Spherical
from .Quaternion import Quaternion
from Spherical import Spherical
from Quaternion import Quaternion
## A thing is the basic building block
#
## A thing is the basic building block
class Thing:
class Type:
Undetermined = 0x00
@ -56,6 +59,8 @@ class Thing:
return thing
return None
## Update all things
@staticmethod
def UpdateAll(currentTime):
for thing in Thing.allThings:
if thing is not None:

0
test/__init__.py Normal file
View File

Binary file not shown.

37
test/thing_test.py Normal file
View File

@ -0,0 +1,37 @@
import unittest
import time
from Thing import Thing
from Participant import Participant
class ThingTest(unittest.TestCase):
def test_client_msg(self):
participant: Participant = Participant(ipAddress="127.0.0.1", port=7681)
thing: Thing = Thing()
milliseconds = time.time() * 1000
thing.update(milliseconds)
Thing.UpdateAll(milliseconds)
start_time = milliseconds
while milliseconds < start_time + 5000:
milliseconds = time.time() * 1000
participant.Update(milliseconds)
def test_something(self):
self.assertEqual(1 + 1, 2)
def test_another_thing(self):
self.assertTrue(isinstance("hello", str))
def test_yet_another_thing(self):
self.assertFalse(3 > 5)
def test_more_tests(self):
self.assertIn(3, [1, 2, 3, 4])
def test_even_more_tests(self):
self.assertIsNone(None)
if __name__ == '__main__':
unittest.main()