поправил таймер
This commit is contained in:
@@ -5,20 +5,32 @@ from datetime import datetime
|
||||
import logging
|
||||
import os
|
||||
import time
|
||||
import requests
|
||||
|
||||
|
||||
SETTING = "19200,RS-485"
|
||||
HOST = "192.168.127.254"
|
||||
PORT = 1993
|
||||
PATH = (
|
||||
r"D:\ГРАФИКА\БАСКЕТБОЛ\ЕДИНАЯ ЛИГА ВТБ 2022-2023\python\JSON\timer_basketball.json"
|
||||
)
|
||||
|
||||
session = requests.Session()
|
||||
session.headers.update({"Connection": "keep-alive"})
|
||||
|
||||
def send_data(name, value):
|
||||
url = "http://127.0.0.1:8088/API/"
|
||||
par = "SetText" if name.split(".")[1] == "Text" else "SetImage"
|
||||
params = {
|
||||
"Function": par,
|
||||
# "Input": 41,
|
||||
"Input": "SCOREBUG",
|
||||
"SelectedName": name,
|
||||
"Value": value,
|
||||
}
|
||||
session.get(url, params=params)
|
||||
|
||||
|
||||
def parse(line):
|
||||
if len(line) > 6:
|
||||
try:
|
||||
with open(PATH, "r", encoding="utf-8") as f:
|
||||
new_data = json.load(f)
|
||||
timer_bool = 0
|
||||
if b"\xf87" in line:
|
||||
temp_new = str(line.split(b"\xf87")[1])
|
||||
@@ -45,13 +57,7 @@ def parse(line):
|
||||
points2 = (temp_new[11:14]).strip()
|
||||
fouls1 = temp_new[15]
|
||||
fouls2 = temp_new[16]
|
||||
new_data[0]["points1"] = points1
|
||||
new_data[0]["points2"] = points2
|
||||
new_data[0]["foul1"] = fouls1
|
||||
new_data[0]["foul2"] = fouls2
|
||||
new_data[0]["quarter"] = quarter
|
||||
|
||||
path_pic = r"D:\ГРАФИКА\БАСКЕТБОЛ\ЕДИНАЯ ЛИГА ВТБ 2022-2023\Scorebug Indicators"
|
||||
|
||||
attack_display = temp_new[51:53]
|
||||
if attack_display == "30":
|
||||
time_attack = ""
|
||||
@@ -77,18 +83,10 @@ def parse(line):
|
||||
if timer_str == "0:00":
|
||||
timer_str = "0.0"
|
||||
|
||||
new_data[0]["timeGFX"] = timer_str
|
||||
new_data[0]["time_attackGFX"] = time_attack
|
||||
new_data[0]["time_attac_pic"] = path_pic
|
||||
|
||||
print(new_data[0]["timeGFX"], new_data[0]["time_attackGFX"])
|
||||
try:
|
||||
with open(PATH, "w", encoding="utf-8") as file:
|
||||
json.dump(new_data, file, ensure_ascii=False, indent=4)
|
||||
except Exception:
|
||||
print(Exception)
|
||||
pass
|
||||
# logging.debug(new_data)
|
||||
send_data("TIMER.Text", timer_str)
|
||||
send_data("24sec.Text", time_attack)
|
||||
send_data("SCORE1.Text", points1)
|
||||
send_data("SCORE2.Text", points2)
|
||||
except Exception as ex:
|
||||
print(ex)
|
||||
pass
|
||||
@@ -121,20 +119,6 @@ def main():
|
||||
filename=LogFileName,
|
||||
filemode="w",
|
||||
)
|
||||
new_data = {
|
||||
"timeGFX": "0.0",
|
||||
"time_attackGFX": "",
|
||||
"quarter": "0",
|
||||
"points1": "0",
|
||||
"points2": "0",
|
||||
"foul1": "0",
|
||||
"foul2": "0",
|
||||
"foul_pic1": "",
|
||||
"foul_pic2": "",
|
||||
"time_attac_pic": "",
|
||||
}
|
||||
with open(PATH, "w", encoding="utf-8") as file:
|
||||
json.dump([new_data], file, ensure_ascii=False, indent=4)
|
||||
|
||||
try:
|
||||
tcp_socket = socket(AF_INET, SOCK_STREAM)
|
||||
|
||||
Reference in New Issue
Block a user