You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
212 lines
5.5 KiB
Python
212 lines
5.5 KiB
Python
import sys
|
|
import os
|
|
import datetime
|
|
from peewee import *
|
|
import json
|
|
|
|
|
|
from utils.DBModels.BaseModel import BaseModel
|
|
|
|
sys.path.append('../')
|
|
sys.path.append('../../../')
|
|
|
|
|
|
|
|
|
|
class PressureTranslationBlock(BaseModel):
|
|
index = CharField()
|
|
paramName = CharField()
|
|
objectType = CharField()
|
|
dataType = CharField()
|
|
saveType = CharField()
|
|
dataSize = CharField()
|
|
accessType = CharField()
|
|
transferType = CharField()
|
|
description = CharField()
|
|
createTime = CharField()
|
|
|
|
# 查询设备是否存在
|
|
@classmethod
|
|
def getallParame(cls):
|
|
params = cls.get_all()
|
|
if params is 'error':
|
|
return
|
|
l = []
|
|
for x in params:
|
|
l.append([x.index, x.paramName, x.description, x.dataType, x.accessType, x.dataSize])
|
|
return l
|
|
|
|
@classmethod
|
|
def getallParameAndID(cls):
|
|
params = cls.get_all()
|
|
if params is 'error':
|
|
return
|
|
l = []
|
|
for x in params:
|
|
l.append([x.id, x.index, x.paramName, x.description, x.dataType, x.accessType, x.dataSize])
|
|
return l
|
|
|
|
@classmethod
|
|
def getByName(cls, paramName):
|
|
try:
|
|
return cls.get(cls.paramName == str(paramName))
|
|
except Exception as e:
|
|
return
|
|
|
|
@classmethod
|
|
def getIndex(cls):
|
|
params = cls.get_all()
|
|
if params is 'error':
|
|
return
|
|
|
|
return params.index
|
|
|
|
def addParame(self, index, paramName, objectType, dataType, saveType, dataSize, accessType, transferType, description):
|
|
self.index = index
|
|
self.paramName = paramName
|
|
self.objectType = objectType
|
|
self.dataType = dataType
|
|
self.saveType = saveType
|
|
self.dataSize = dataSize
|
|
self.accessType = accessType
|
|
self.transferType = transferType
|
|
self.description = description
|
|
self.createTime = datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d %H:%M:%S')
|
|
# print(self.createTime)
|
|
self.save()
|
|
|
|
|
|
|
|
|
|
|
|
class PhysicalBlock(PressureTranslationBlock):
|
|
index = CharField()
|
|
paramName = CharField()
|
|
objectType = CharField()
|
|
dataType = CharField()
|
|
saveType = CharField()
|
|
dataSize = CharField()
|
|
accessType = CharField()
|
|
transferType = CharField()
|
|
description = CharField()
|
|
createTime = CharField()
|
|
|
|
|
|
|
|
class AIFunctionBlock(PressureTranslationBlock):
|
|
index = CharField()
|
|
paramName = CharField()
|
|
objectType = CharField()
|
|
dataType = CharField()
|
|
saveType = CharField()
|
|
dataSize = CharField()
|
|
accessType = CharField()
|
|
transferType = CharField()
|
|
description = CharField()
|
|
createTime = CharField()
|
|
|
|
class TemperatureTranslationBlock(PressureTranslationBlock):
|
|
index = CharField()
|
|
paramName = CharField()
|
|
objectType = CharField()
|
|
dataType = CharField()
|
|
saveType = CharField()
|
|
dataSize = CharField()
|
|
accessType = CharField()
|
|
transferType = CharField()
|
|
description = CharField()
|
|
createTime = CharField()
|
|
|
|
class LevelTranslationBlock(PressureTranslationBlock):
|
|
index = CharField()
|
|
paramName = CharField()
|
|
objectType = CharField()
|
|
dataType = CharField()
|
|
saveType = CharField()
|
|
dataSize = CharField()
|
|
accessType = CharField()
|
|
transferType = CharField()
|
|
description = CharField()
|
|
createTime = CharField()
|
|
|
|
|
|
class FlowTranslationBlock(PressureTranslationBlock):
|
|
index = CharField()
|
|
paramName = CharField()
|
|
objectType = CharField()
|
|
dataType = CharField()
|
|
saveType = CharField()
|
|
dataSize = CharField()
|
|
accessType = CharField()
|
|
transferType = CharField()
|
|
description = CharField()
|
|
createTime = CharField()
|
|
|
|
class WiKaLevelTranslationBlock(PressureTranslationBlock):
|
|
index = CharField()
|
|
paramName = CharField()
|
|
objectType = CharField()
|
|
dataType = CharField()
|
|
saveType = CharField()
|
|
dataSize = CharField()
|
|
accessType = CharField()
|
|
transferType = CharField()
|
|
description = CharField()
|
|
createTime = CharField()
|
|
|
|
class KaiFengFlowTranslationBlock(PressureTranslationBlock):
|
|
index = CharField()
|
|
paramName = CharField()
|
|
objectType = CharField()
|
|
dataType = CharField()
|
|
saveType = CharField()
|
|
dataSize = CharField()
|
|
accessType = CharField()
|
|
transferType = CharField()
|
|
description = CharField()
|
|
createTime = CharField()
|
|
|
|
|
|
class UnitTable(BaseModel):
|
|
unitValue = CharField()
|
|
unitSymbol = CharField()
|
|
description = CharField()
|
|
state = CharField()
|
|
createTime = CharField()
|
|
|
|
# 查询设备是否存在
|
|
|
|
@classmethod
|
|
def getByValue(cls, unitValue):
|
|
try:
|
|
return cls.get(cls.unitValue == str(unitValue))
|
|
except Exception as e:
|
|
return
|
|
@classmethod
|
|
def getAbleUint(cls):
|
|
units = cls.select().where(cls.state == '1')
|
|
# print(units,444)
|
|
l = []
|
|
for unit in units:
|
|
l.append([unit.unitValue, unit.unitSymbol])
|
|
return l
|
|
|
|
@classmethod
|
|
def getUnitSymbolByUnitValue(cls, unitValue):
|
|
try:
|
|
unit = cls.get(cls.unitValue == unitValue)
|
|
return unit.unitSymbol
|
|
except Exception as e:
|
|
# print(e)
|
|
return
|
|
# print(units,444)
|
|
|
|
def addParame(self, unitValue, unitSymbol, description, state):
|
|
self.unitValue = unitValue
|
|
self.unitSymbol = unitSymbol
|
|
self.description = description
|
|
self.state = state
|
|
self.createTime = datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d %H:%M:%S')
|
|
# print(self.createTime)
|
|
self.save()
|