|
|
|
@ -463,15 +463,3 @@ class DevicesManange():
|
|
|
|
|
except Exception as e:
|
|
|
|
|
return print(e)
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def update_or_insert_variable(self, variable_name, value):
|
|
|
|
|
# 这里假设有一个数据库模型类DeviceVariable用于操作变量数据
|
|
|
|
|
from utils.DBModels.DeviceModels import DeviceVariable
|
|
|
|
|
variable = DeviceVariable.get_by_name(variable_name)
|
|
|
|
|
if variable:
|
|
|
|
|
# 如果变量存在,则更新其值
|
|
|
|
|
variable.value = value
|
|
|
|
|
variable.save()
|
|
|
|
|
else:
|
|
|
|
|
# 如果变量不存在,则创建新记录
|
|
|
|
|
DeviceVariable.create(name=variable_name, value=value)
|
|
|
|
|