constant.py 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. # ==========算法中涉及的相关变量==========
  2. # EnergyMode = {'极限节能': 1, '标准节能': 2, '安全节能': 3} # 控制模式决定温度限制值,先写死,后续作为产品配置参数
  3. # 在进行温湿度计算时,按照以下温度和湿度范围进行筛选,避免异常数据导致计算发生错误
  4. TerminalTempRange = {'lowerLimit': 0, 'upperLimit': 50}
  5. TerminalHumiRange = {'lowerLimit': 0, 'upperLimit': 100}
  6. # 在进行温湿度限值修正时,用到以下阈值,先写死,后续视情况优化
  7. ModifyTempHumiPara = {'threshold': 0.5, 'quantile': 0.75} # 分别代表阈值和分位数
  8. # 根据监测点情况进行水温计算时,用到以下系数,分别代表温度超标、湿度超标、露点超标、温度不超标、湿度不超标
  9. Coefficient = {'outTemp': 1, 'outHumi': 0.1, 'outDewPoint': 1.25, 'inTemp': 0.5, 'inHumi': 0.05}
  10. # 温湿度超标情况判断结果
  11. ExcessDescription = {'0': '未超标', '1': '温度超标', '2': '露点超标', '3': '湿度超标'}
  12. ExpectedStructure = {
  13. "terminalInfo": ["ahuMeterId", "ahuName", "ahuStartTime", "coolingTempUpper", "coolingHumiUpper", "tempReal",
  14. "humiReal"],
  15. "controlConfigInfo": ["handleService", "controlMode", "isHardwareControl", "calPeriod", "minControlStep",
  16. "chillerWaterTempSetInitial", "chillerWaterTempSetUpper", "chillerWaterTempSetLower",
  17. "energyMode", "controlBasis", "tempMargin", "humiMargin", "mainTempMode", "samplePeriod",
  18. "upTempControlPeriod", "downTempControlPeriod"],
  19. "chillerConfigInfo": ["waterTempControlMode", "isContinuousRun", "coolingShutdownOffset", "coolingRestartOffset",
  20. "safetyPreDiffLowerLimit", "safetyLoadRatioLowerLimit", "chillerTempStep"],
  21. "chillerSafetyPara": ["circuitNumber", "circuitParameter"],
  22. "stationInfo": ["userName", "stationName", "stationId", "runMode", "triggerTime", "chilledWaterMainTempOut",
  23. "chilledWaterMainTempIn", "allChillersInfo"],
  24. "chillerInfo": ["chillerId", "chillerName", "capacityRated", "refriType", "chillerWaterTempSet",
  25. "chillerOffTimeLatest", "offSetTempLatestCooling", "chillerWaterTempOut", "chillerWaterTempIn",
  26. "runStatus", "chillerPowerRatio", "loadRate", "upControlTimeLatest", "downControlTimeLatest"],
  27. }
  28. # def check_data_integrity(dic_input):
  29. # # 定义预期的数据结构
  30. # missing_fields = []
  31. #
  32. # # 检查顶层字段缺失
  33. # for top_key in ExpectedStructure:
  34. # if top_key not in dic_input:
  35. # missing_fields.append(top_key)
  36. #
  37. # # 检查子字段缺失
  38. # # for top_key in ExpectedStructure:
  39. # if top_key in dic_input:
  40. # current_data = dic_input[top_key]
  41. # if isinstance(current_data, dict):
  42. # expected_subkeys = ExpectedStructure[top_key]
  43. # for sub_key in expected_subkeys:
  44. # if sub_key not in current_data:
  45. # missing_fields.append(f"{top_key}.{sub_key}")
  46. #
  47. # # 检查空值的递归函数
  48. # def find_empty_fields(data, parent_path='', empty_fields=None):
  49. # if empty_fields is None:
  50. # empty_fields = set()
  51. #
  52. # if isinstance(data, dict):
  53. # for key, value in data.items():
  54. # new_path = f"{parent_path}.{key}" if parent_path else key
  55. # # 检查当前值是否为空
  56. # if value is None:
  57. # empty_fields.add(new_path)
  58. # elif isinstance(value, str) and value.strip() == '':
  59. # empty_fields.add(new_path)
  60. # elif isinstance(value, (list, dict)) and not value:
  61. # empty_fields.add(new_path)
  62. # # 递归检查子元素
  63. # find_empty_fields(value, new_path, empty_fields)
  64. # elif isinstance(data, list):
  65. # if not data: # 空列表
  66. # empty_fields.add(parent_path)
  67. # else:
  68. # for index, item in enumerate(data):
  69. # new_path = f"{parent_path}[{index}]"
  70. # # 检查当前元素是否为空
  71. # if item is None:
  72. # empty_fields.add(new_path)
  73. # elif isinstance(item, str) and item.strip() == '':
  74. # empty_fields.add(new_path)
  75. # elif isinstance(item, (list, dict)) and not item:
  76. # empty_fields.add(new_path)
  77. # # 递归检查子元素
  78. # find_empty_fields(item, new_path, empty_fields)
  79. # else:
  80. # # 检查字符串是否为空
  81. # if isinstance(data, str) and data.strip() == '':
  82. # empty_fields.add(parent_path)
  83. # return empty_fields
  84. #
  85. # # 查找所有空值路径
  86. # empty_paths = find_empty_fields(dic_input)
  87. #
  88. # return missing_fields, empty_paths
  89. #
  90. # dic_input = {}
  91. #
  92. # # 执行检查
  93. # missing_fields, empty_paths = check_data_integrity(dic_input)
  94. #
  95. # # 输出结果
  96. # print("输入参数中缺失关键字段,退出水温智控算法计算")
  97. # print("输入参数中关键数据存在空值,退出水温智控算法计算")
  98. # print("缺失字段检查结果:")
  99. # if missing_fields:
  100. # print("缺失字段:")
  101. # print("\n".join(missing_fields))
  102. # else:
  103. # print("无缺失字段")
  104. #
  105. # print("\n空值字段检查结果:")
  106. # if empty_paths:
  107. # print("存在空值的字段路径:")
  108. # print("\n".join(sorted(empty_paths)))
  109. # else:
  110. # print("无空值字段")