Skip to content
Snippets Groups Projects
Commit 81e96177 authored by marc.laugt's avatar marc.laugt
Browse files

fichiers déplacés

parent c4547017
No related branches found
No related tags found
No related merge requests found
Showing
with 661 additions and 80 deletions
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8"/>
<title>Inscription Bol d'or d'hiver</title>
</head>
<header>
</header>
<body>
<text id="btnTxt">Formulaire d'inscription</text>
<main>
<form method="POST">
<label>Nom equipe</label><br>
<input type="text" id="equipe"><br>
<label>Tag id</label><br>
<input type="text" id="tag" >
<button id="lastTag">Recuper Tag Scanné</button><br>
<button id="enterData">Inscrire l'équipe</button>
</form>
</main>
<h2>Gestion de la course</h2>
<button id="raceControl">Commencer la course</button>
</body>
<script>
const btnPost = document.getElementById("enterData");
const btnRaceControl = document.getElementById("raceControl");
const btnGet = document.getElementById("lastTag");
btnPost.addEventListener("click",submitEntry);
btnGet.addEventListener("click",getLastTag);
btnRaceControl.addEventListener("click",submitStartContol);
isRaceStarted = false;
fetch('http://localhost:8000/isRaceStarted')
.then((response) => response.json())
.then((res) => {
isRaceStarted = res.data
if(isRaceStarted) {
btnRaceControl.innerHTML = "Finir la course"
}
});
function submitStartContol(event) {
var raw = "";
var requestOptions = {
method: 'POST',
body: raw,
redirect: 'follow'
};
isRaceStarted = !isRaceStarted
fetch("http://localhost:8000/raceContol?status="+isRaceStarted,requestOptions)
.then(response => response.json())
.then(result => console.log(result))
.catch(error => console.log('error', error));
if(isRaceStarted) {
btnRaceControl.innerHTML = "Finir la course"
}
else {
btnRaceControl.innerHTML = "Commencer la course"
}
}
function submitEntry(event) {
tag = document.getElementById("tag").value;
nomEquipe = document.getElementById("equipe").value;
event.preventDefault();
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"tag_id": tag,
"team_name": nomEquipe
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("http://localhost:8000/registerTag", requestOptions)
.then(response => response.text())
.then((res) => {
document.getElementById("tag").value = ""
document.getElementById("equipe").value = ""
console.log(res)
})
.catch(error => console.log('error', error));
}
function getLastTag(event) {
fetch('http://localhost:8000/LastTagDetected')
.then((response) => response.json())
.then((data) => {
document.getElementById("tag").value = data.data;
console.log(data.data)
});
event.preventDefault();
}
</script>
</html>
FluxOCC.drawio.png

28.4 KiB

Routeur
Ballenberg
admin
sc4lpsc4lp
lecteur:
USR-WIFI232-610_5EC8
10.10.100.254
admin
admin
\ No newline at end of file
File added
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8"/>
<title>Affichage des passages</title>
</head>
<header>
</header>
<body onload="showAlert()">
<h3>Filtres: </h3>
<select onchange="updateFilter()" id="teams" name="teams">
</select>
<h3 id="filterType">Pas de filtres</h3>
<p id="loadRes"></p>
</body>
<script>
const dropdownList = document.getElementById("teams")
const filterTypeElem = document.getElementById("filterType")
const requestOptions = {
method: 'GET',
redirect: 'follow'
};
var passagesUrl = 'http://localhost:8000/passages'
fetch("http://localhost:8000/teams", requestOptions)
.then(response => response.json())
.then((res) => {
data = res.data;
console.log(data)
res = "<option default value='all'>All teams</option>"
data.forEach(e => {
res += "<option value='"+e.team_name+"''>"+e.team_name+"</option>"
});
res += "</table>";
dropdownList.innerHTML = res;
});
function updateFilter() {
if(dropdownList.value == 'all') {
passagesUrl = 'http://localhost:8000/passages'
filterTypeElem.innerHTML = "Pas de filtres"
showAlert()
}
else {
passagesUrl = 'http://localhost:8000/passagesByTeam?teamName='+dropdownList.value
filterTypeElem.innerHTML = "Filtré par équipe: "+dropdownList.value
showAlert()
}
}
function showAlert(){
cmpt = 0
res = "<table><tr><th>Position</th><th>Temps</th><th>Equipe</th></tr>"
fetch(passagesUrl)
.then((response) => response.json())
.then((data) => {
x = data.data;
x.forEach(element => {
cmpt = cmpt + 1;
res += "<tr><td>" + cmpt + "</td><td> " + element.timestamp + "</td><td>" + element.team_name + "</td></tr>";
});
res += "</table>";
document.getElementById("loadRes").innerHTML = res;
});
}
const interval = setInterval(function() {
showAlert()
}, 5000);
</script>
</html>
equipe ... Tag : UID 0x.....
1) scan UID (appairage dans Genève plage), rentrée dans une base de donnée (Id, équipe)
2) passe à coté de la bouée : lit ID + timestamp, -> Base de donnée
3) tableau dynamique avec équipe et heure de passage
visble depuis smartphone
(organisateurs, Users)
# Rfid
# API-object-comm
## 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:
## install Requirement
```
cd existing_repo
git remote add origin https://gitedu.hesge.ch/marc.laugt/rfid.git
git branch -M main
git push -uf origin main
pip install fastapi
pip install pydantic
pip install starlette
pip install databases
pip install databases[aiosqlite]
pip install uvicorn
ou : sudo apt install uvicorn
```
## Integrate with your tools
- [ ] [Set up project integrations](https://gitedu.hesge.ch/marc.laugt/rfid/-/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/)
- [ ] [Automatically merge when pipeline succeeds](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)
***
## Launch API
# 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!). Thank you 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.
```
uvicorn api:app --reload --host 0.0.0.0 --port 8000
```
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
## Rapport:
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.
rappeler:
- le besoin: on veut qu'une equipe voulant participer au bol d'or puisse aller voir l'organisateur pour s'inscrire. Pendant l'inscription on attribue un tag à cette équipe. Pour cela le tag doit être scanné et dois pouvoir être récupéré sur l'interface d'inscription. Ensuite lors de la course, les spectateurs doivent avoir accès aux passages des équipes au checkpoint et doivent pouvoir voir le momment au-quel ils ont passé le checkpoint.
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.
- le cahier des charges
expliquer comment ont à répondu à ce besoin avec un diagramme de flux
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
faire un manuel utilisateur (1 page recto/verso)
## License
For open source projects, say how it is licensed.
temps: 8/9min par équipe
## 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.
faire une vidéo démo de 2 min montrant notre appli en marche pour montrer pendant la présentation
File added
File added
File added
File added
File added
File added
File added
File added
http://localhost:8000/
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Windows.Forms;
namespace Ethernet_data
{
public class AutoConnect
{
private Socket UDP;
private bool _closeing = false;
public bool Closeing { get => _closeing; set => _closeing = value; }
private bool resing = false;
private IPEndPoint iep;
private UdpClient UDP_send;
TcpListener m_sockListener=null;
public delegate void addDeviceHandle(DeviceInfo deviceInfo);
public event addDeviceHandle AddDeviceEvent;
/// <summary>
/// The response of the listening device to the broadcast 监听设备对广播的响应
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public Object read_message(byte[] data)
{
UDP = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
UDP.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
IPEndPoint iep1 = new IPEndPoint(IPAddress.Any, 65534);
EndPoint Remote = (EndPoint)(iep1);
UDP.Bind(Remote);
iep = new IPEndPoint(IPAddress.Parse("255.255.255.255"), 65533);
UDP_send = new UdpClient();
UDP_send.Send(data, data.Length, iep);//发送数据
UDP_send.Close();
Object result = listen();
return result;
}
/// <summary>
/// listen
/// </summary>
/// <returns></returns>
private Object listen()//监听
{
try
{
byte[] receive_data = new byte[1024];
bool result = false;
int delaytime = 0;
while (true)
{
Thread.Sleep(100);
if (delaytime++ > 20)
{
return result;
}
if (UDP != null)
{
if (UDP.Available > 0)
{
delaytime = 0;
resing = true;
UDP.Receive(receive_data);//返回接受的数据 Encoding.UTF8.GetString
resing = false;
// if (receive_data.Length != 208) continue;
if (receive_data[207] != 13) continue;
if (receive_data[1] == 0x10 && receive_data[2] == 0x04) //获取设备应答
{
DeviceInfo deviceInfo= GetDeviceInfos(receive_data);
if (deviceInfo != null&&AddDeviceEvent!=null)
{
AddDeviceEvent(deviceInfo);
}
delaytime = 0;
result = true;
}
else if (receive_data[1] == 0x10 && receive_data[2] == 0x06) //设置设备IP地址应答
{
if (receive_data[77] > 0)
{
return false;
}
return true;
}
else if (receive_data[1] == 0x10 && receive_data[2] == 0x1F) //设置设备工作模式应答
{
if (receive_data[119] == 0)
{
return false;
}
return true;
}
}
}
}
}
finally
{
if (UDP != null) UDP.Close();
}
}
/// <summary>
/// get the deviceInfo form bytes data 从字节数组解析设备信息
/// </summary>
/// <param name="receive_data"></param>
/// <returns></returns>
private DeviceInfo GetDeviceInfos(byte[] receive_data)
{
DeviceInfo deviceInfo = new DeviceInfo();
string devicename, IP, SubnetMask, Gateway, MAC;
MAC = receive_data[72] + "-" + receive_data[73] + "-" + receive_data[74] + "-" + receive_data[75] + "-" + receive_data[76] + "-" + receive_data[77];
IP = receive_data[78] + "." + receive_data[79] + "." + receive_data[80] + "." + receive_data[81];
SubnetMask = receive_data[82] + "." + receive_data[83] + "." + receive_data[84] + "." + receive_data[85];
Gateway = receive_data[86] + "." + receive_data[87] + "." + receive_data[88] + "." + receive_data[89];
byte[] name = new byte[21];
Array.Copy(receive_data, 90, name, 0, 21);
devicename = Encoding.Default.GetString(name);
devicename = devicename.Substring(0, devicename.IndexOf('\0'));
deviceInfo.IP = IP;
deviceInfo.MAC = MAC;
deviceInfo.SubnetMask = SubnetMask;
deviceInfo.Gateway = Gateway;
deviceInfo.Devicename = devicename;
return deviceInfo;
}
/// <summary>
/// get the reader power by deviceIp 根据设备ip获取设备功率
/// </summary>
/// <param name="ip"></param>
/// <param name="port"></param>
/// <param name="deviceIp"></param>
/// <param name="deviceCount"></param>
/// <returns></returns>
public string GetPower(string ip, string port, string deviceIp, int deviceCount)
{
if (m_sockListener != null)
{
m_sockListener.Stop();
}
try
{
IPAddress localAddr = IPAddress.Parse(ip);
m_sockListener = new TcpListener(localAddr, int.Parse(port));
}
catch { }
m_sockListener.ExclusiveAddressUse = false;
m_sockListener.Start(deviceCount);
Thread.Sleep(500);
int delaytime = 30;
TcpClient tcpclient_tmp = null;
bool result = false;
while (delaytime-- > 0)
{
try
{
if (m_sockListener.Pending())
{
tcpclient_tmp = m_sockListener.AcceptTcpClient();//侦听到连接后创建客户端连接TcpClient
if (tcpclient_tmp != null)
{
string iptmp1 = tcpclient_tmp.Client.RemoteEndPoint.ToString();
iptmp1 = iptmp1.Substring(0, iptmp1.IndexOf(':'));
if (tcpclient_tmp.Connected == true && deviceIp == iptmp1)
{
string value = getDB_tcpip(tcpclient_tmp);
m_sockListener.Stop();
return value;
}
else {
tcpclient_tmp.Close();
}
}
}
}
catch (Exception ex)
{
}
}
m_sockListener.Stop();
return "";
}
/// <summary>
/// set the reader power by deviceIp 根据设备ip设置设备功率
/// </summary>
/// <param name="ip"></param>
/// <param name="port"></param>
/// <param name="deviceIp"></param>
/// <param name="deviceCount"></param>
/// <param name="value"></param>
/// <returns></returns>
public bool SetPower(string ip, string port, string deviceIp, int deviceCount, string value)
{
if (m_sockListener != null)
{
m_sockListener.Stop();
}
try
{
IPAddress localAddr = IPAddress.Parse(ip);
m_sockListener = new TcpListener(localAddr, int.Parse(port));
}
catch { }
m_sockListener.ExclusiveAddressUse = false;
m_sockListener.Start(deviceCount);
Thread.Sleep(500);
int delaytime = 30;
TcpClient tcpclient_tmp = null;
bool result = false;
while (delaytime-- > 0)
{
try
{
if (m_sockListener.Pending())
{
tcpclient_tmp = m_sockListener.AcceptTcpClient();//侦听到连接后创建客户端连接TcpClient
if (tcpclient_tmp != null)
{
string iptmp1 = tcpclient_tmp.Client.RemoteEndPoint.ToString();
iptmp1 = iptmp1.Substring(0, iptmp1.IndexOf(':'));
if (tcpclient_tmp.Connected == true && deviceIp == iptmp1)
{
bool isok= setDB_tcpip(tcpclient_tmp, value);
tcpclient_tmp.Close();
m_sockListener.Stop();
return isok;
}
}
}
}
catch (Exception ex)
{
}
}
m_sockListener.Stop();
return false;
}
/// <summary>
/// get the reader power 读取功率
/// </summary>
/// <param name="tcpclient"></param>
/// <returns></returns>
private string getDB_tcpip(TcpClient tcpclient)
{
byte Addr = ReadAddr(tcpclient);
if (Addr == 0) return "";
byte[] sendBuf = new byte[] { Addr, 0x04, 0x4c, 0x03 };
NetworkStream netStream;
try
{
netStream = tcpclient.GetStream();//得到网络流
netStream.Write(sendBuf, 0, sendBuf[1]);
}
catch (Exception exp)
{
MessageBox.Show(exp.Message);
return "";
}
for (int i = 0; i < 20; i++)
{
int count = tcpclient.Available;
if (count >= 6)
{
byte[] recvBuf = new byte[count];
try
{
int recvLength = netStream.Read(recvBuf, 0, count);
if (recvLength >= 6 && recvBuf[0] == 0xFF && recvBuf[1] == 0xFF && recvBuf[4] == 0xEE && recvBuf[5] == 0xEE)
{
byte btDB = recvBuf[3];
string value = (31 - btDB).ToString();
//addinfo("Get Power sucessfully!", false);
return value;
}
}
catch { }
}
System.Threading.Thread.Sleep(50);
}
//addinfo("Get Power failed", true);
return "";
}
/// <summary>
/// set the reader power 设置功率
/// </summary>
/// <param name="tcpclient"></param>
/// <param name="value"></param>
/// <returns></returns>
private bool setDB_tcpip(TcpClient tcpclient,string value)
{
byte Addr = ReadAddr(tcpclient);
if (Addr == 0) return false;
byte btDB = 0;
try
{
btDB = byte.Parse(value);
}
catch (Exception exp)
{
MessageBox.Show(exp.Message);
return false;
}
if (btDB > 31) btDB = 31;
btDB = (byte)(31 - btDB);
byte[] sendBuf = new byte[] { Addr, 0x05, 0xcc, btDB, 0x03 };
NetworkStream netStream;
try
{
netStream = tcpclient.GetStream();//得到网络流
netStream.Write(sendBuf, 0, sendBuf[1]);
}
catch (Exception exp)
{
MessageBox.Show(exp.Message);
return false;
}
for (int i = 0; i < 20; i++)
{
int count = tcpclient.Available;
if (count >= 6)
{
byte[] recvBuf = new byte[count];
try
{
int recvLength = netStream.Read(recvBuf, 0, count);
if (recvLength >= 6 && recvBuf[0] == 0xFF && recvBuf[1] == 0xFF && recvBuf[3] == btDB && recvBuf[4] == 0xEE && recvBuf[5] == 0xEE)
{
//addinfo("Set Power sucessfully!", false);
return true;
}
}
catch { }
}
System.Threading.Thread.Sleep(50);
}
//addinfo("Set Power failed", true);
return false;
}
/// <summary>
/// get the reader id 获取读卡器id
/// </summary>
/// <param name="tcpclient"></param>
/// <returns></returns>
private byte ReadAddr(TcpClient tcpclient)
{
byte addr = 0;
byte[] sendBuf = new byte[] { 0xff, 0xff, 0x08, 0xee, 0xee };
NetworkStream netStream;
try
{
netStream = tcpclient.GetStream();//得到网络流
netStream.Write(sendBuf, 0, 5);
}
catch (Exception exp)
{
//addinfo(exp.Message, true);
return 0;
}
for (int i = 0; i < 20; i++)
{
int count = tcpclient.Available;
if (count >= 5)
{
byte[] recvBuf = new byte[count];
try
{
int recvLength = netStream.Read(recvBuf, 0, count);
if (recvLength >= 5 && recvBuf[0] == 0xFF && recvBuf[1] == 0xFF && recvBuf[3] == 0xEE && recvBuf[4] == 0xEE)
{
addr = recvBuf[2];
break;
}
}
catch (Exception exp)
{
//addinfo(exp.Message, true);
return 0;
}
}
Thread.Sleep(50);
}
return addr;
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment