поправил таймер
This commit is contained in:
@@ -5,20 +5,32 @@ from datetime import datetime
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
import requests
|
||||||
|
|
||||||
|
|
||||||
SETTING = "19200,RS-485"
|
SETTING = "19200,RS-485"
|
||||||
HOST = "192.168.127.254"
|
HOST = "192.168.127.254"
|
||||||
PORT = 1993
|
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):
|
def parse(line):
|
||||||
if len(line) > 6:
|
if len(line) > 6:
|
||||||
try:
|
try:
|
||||||
with open(PATH, "r", encoding="utf-8") as f:
|
|
||||||
new_data = json.load(f)
|
|
||||||
timer_bool = 0
|
timer_bool = 0
|
||||||
if b"\xf87" in line:
|
if b"\xf87" in line:
|
||||||
temp_new = str(line.split(b"\xf87")[1])
|
temp_new = str(line.split(b"\xf87")[1])
|
||||||
@@ -45,13 +57,7 @@ def parse(line):
|
|||||||
points2 = (temp_new[11:14]).strip()
|
points2 = (temp_new[11:14]).strip()
|
||||||
fouls1 = temp_new[15]
|
fouls1 = temp_new[15]
|
||||||
fouls2 = temp_new[16]
|
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]
|
attack_display = temp_new[51:53]
|
||||||
if attack_display == "30":
|
if attack_display == "30":
|
||||||
time_attack = ""
|
time_attack = ""
|
||||||
@@ -77,18 +83,10 @@ def parse(line):
|
|||||||
if timer_str == "0:00":
|
if timer_str == "0:00":
|
||||||
timer_str = "0.0"
|
timer_str = "0.0"
|
||||||
|
|
||||||
new_data[0]["timeGFX"] = timer_str
|
send_data("TIMER.Text", timer_str)
|
||||||
new_data[0]["time_attackGFX"] = time_attack
|
send_data("24sec.Text", time_attack)
|
||||||
new_data[0]["time_attac_pic"] = path_pic
|
send_data("SCORE1.Text", points1)
|
||||||
|
send_data("SCORE2.Text", points2)
|
||||||
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)
|
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
print(ex)
|
print(ex)
|
||||||
pass
|
pass
|
||||||
@@ -121,20 +119,6 @@ def main():
|
|||||||
filename=LogFileName,
|
filename=LogFileName,
|
||||||
filemode="w",
|
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:
|
try:
|
||||||
tcp_socket = socket(AF_INET, SOCK_STREAM)
|
tcp_socket = socket(AF_INET, SOCK_STREAM)
|
||||||
|
|||||||
Reference in New Issue
Block a user