123
This commit is contained in:
@@ -330,7 +330,7 @@ def upload_to_s3(json_data: str):
|
||||
try:
|
||||
client = boto3.client(
|
||||
's3',
|
||||
endpoint_url="http://100.85.52.31:9000" or "https://s3-api.siat-mic.com",
|
||||
endpoint_url="http://100.85.52.31:9000", # or "https://s3-api.siat-mic.com",
|
||||
aws_access_key_id="9bUtQL1Gpo9JB6o3pSGr",
|
||||
aws_secret_access_key="1Qug5H73R3kP8boIHvdVcFtcb1jU9GRWnlmMpx0g"
|
||||
)
|
||||
@@ -340,9 +340,10 @@ def upload_to_s3(json_data: str):
|
||||
url = client.generate_presigned_url(
|
||||
'get_object',
|
||||
Params={'Bucket': "temp", 'Key': file_name},
|
||||
ExpiresIn=3600
|
||||
ExpiresIn=36000
|
||||
)
|
||||
return url.replace("http://100.85.52.31:9000" or "", "https://s3-api.siat-mic.com")
|
||||
# return url.replace("http://100.85.52.31:9000" or "", "https://s3-api.siat-mic.com")
|
||||
return url
|
||||
|
||||
except Exception as e:
|
||||
# print(e)
|
||||
@@ -409,7 +410,6 @@ def get_latest_exp_log():
|
||||
# 找到最新修改的文件
|
||||
latest_file = pl_files[-1]
|
||||
res = f"找到最新的PL数据文件: {latest_file}"
|
||||
# print(res)
|
||||
return res
|
||||
|
||||
pl_latest = get_pl_latest_file()
|
||||
@@ -417,6 +417,11 @@ def get_latest_exp_log():
|
||||
|
||||
return pl_latest + "\n" + uv_latest
|
||||
|
||||
|
||||
def read_data():
|
||||
get_latest_exp_log()
|
||||
|
||||
|
||||
def default_func():
|
||||
return "Approved. Proceed as planned!"
|
||||
|
||||
@@ -505,8 +510,8 @@ def sendScheme2RobotWorkstation(task_id: str, scheme_url: str):
|
||||
return {"status": "error", "message": f"Error reading scheme_url: {e}"}
|
||||
|
||||
import requests
|
||||
# url = "http://100.122.132.69:50000/sendScheme2RobotPlatform"
|
||||
url = "http://localhost:50000/sendScheme2RobotWorkstation"
|
||||
url = "http://100.122.132.69:50000/sendScheme2RobotPlatform"
|
||||
# url = "http://localhost:50000/sendScheme2RobotWorkstation"
|
||||
data = {"status": "ok"}
|
||||
try:
|
||||
response = requests.post(url, json=robot_scheme)
|
||||
@@ -579,8 +584,8 @@ def sendScheme2MobileRobot(task_id: str, scheme_url: str):
|
||||
return {"status": "error", "message": f"Error reading scheme_url: {e}"}
|
||||
|
||||
import requests
|
||||
# url = "http://100.122.132.69:50000/sendScheme2RobotPlatform"
|
||||
url = "http://localhost:50000/sendScheme2MobileRobot"
|
||||
url = "http://100.122.132.69:50000/sendScheme2RobotPlatform"
|
||||
# url = "http://localhost:50000/sendScheme2MobileRobot"
|
||||
data = {"status": "ok"}
|
||||
try:
|
||||
response = requests.post(url, json=robot_scheme)
|
||||
@@ -590,5 +595,42 @@ def sendScheme2MobileRobot(task_id: str, scheme_url: str):
|
||||
print(f"Error sending scheme to robot workstation: {e}")
|
||||
return None
|
||||
|
||||
def readPLdata():
|
||||
def list_to_markdown_table(data):
|
||||
# 拆分表头和数据行
|
||||
headers = data[0].split("\t") # 假设列之间用制表符(\t)分隔
|
||||
rows = [line.split("\t") for line in data[1:]]
|
||||
|
||||
# 创建表头部分
|
||||
header_row = "| " + " | ".join(headers) + " |"
|
||||
separator_row = "| " + " | ".join(["---"] * len(headers)) + " |"
|
||||
|
||||
# 创建数据行部分
|
||||
data_rows = []
|
||||
for row in rows:
|
||||
data_rows.append("| " + " | ".join(row) + " |")
|
||||
|
||||
# 合并所有部分
|
||||
markdown_table = "\n".join([header_row, separator_row] + data_rows)
|
||||
return markdown_table
|
||||
|
||||
import requests
|
||||
url = "http://100.122.132.69:50000/getPLdata"
|
||||
try:
|
||||
response = requests.get(url)
|
||||
response.raise_for_status()
|
||||
scheme_content = response.text
|
||||
table = scheme_content.split("Data Points\r\n")[0].split("Peaks\r\n")[-1].split("\r\n")
|
||||
table = [t for t in table if t.strip()]
|
||||
md_table = list_to_markdown_table(table)
|
||||
max_pl = table[1].split('\t')[2]
|
||||
return md_table + "\n" + f"The max PL value in this expriment is {max_pl}"
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(sendScheme2RobotWorkstation(task_id="task_20250122133404", scheme_url="https://s3-api.siat-mic.com/temp/robotExprimentScheme_task_20250122133404.json?AWSAccessKeyId=9bUtQL1Gpo9JB6o3pSGr&Signature=o9SGRdIN6h6%2BL8V7BCYALTc5s8k%3D&Expires=1737527678"))
|
||||
# print(sendScheme2RobotWorkstation(task_id="20250225173342", scheme_url="http://100.85.52.31:9000/temp/robotExprimentScheme_task_20250225173342.json?AWSAccessKeyId=9bUtQL1Gpo9JB6o3pSGr&Signature=bkfes1Nv%2BVzwiUj05p7uHk%2B0P9g%3D&Expires=1740512067"))
|
||||
# print(get_latest_exp_log())
|
||||
print(readPLdata())
|
||||
Reference in New Issue
Block a user