添加native.api源码;临时处理run_simulation中iot数据库name的判断

This commit is contained in:
2026-03-03 09:47:13 +08:00
parent 1d662f973a
commit e7a3aec02f
203 changed files with 9470 additions and 6 deletions
+40
View File
@@ -0,0 +1,40 @@
from .database import *
def get_title_schema(name: str) -> dict[str, dict[str, Any]]:
return {'value': {'type': 'float', 'optional': False, 'readonly': False}}
def get_title(name: str) -> dict[str, Any]:
title = read(name, 'select * from title')
return { 'value': title['value'] }
def _set_title(name: str, cs: ChangeSet) -> DbChangeSet:
new = cs.operations[0]['value']
old = get_title(name)['value']
redo_sql = f"update title set value = '{new}';"
undo_sql = f"update title set value = '{old}';"
redo_cs = g_update_prefix | { 'type': 'title', 'value': new }
undo_cs = g_update_prefix | { 'type': 'title', 'value': old }
return DbChangeSet(redo_sql, undo_sql, [redo_cs], [undo_cs])
def set_title(name: str, cs: ChangeSet) -> ChangeSet:
return execute_command(name, _set_title(name ,cs))
def inp_in_title(section: list[str]) -> str:
if section == []:
return str('')
title = '\n'.join(section)
return str(f"update title set value = '{title}';")
def inp_out_title(name: str) -> list[str]:
obj = str(get_title(name)['value'])
return obj.split('\n')