config.py 6.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import pymysql
  2. class db_config:
  3. def __init__(self):
  4. self.db_ip = "192.168.1.200" # 数据库IP地址
  5. self.db_port = 3306 # 端口号
  6. self.db_name = "xm_project" # 数据库名
  7. self.db_user = "zx" # 用户名
  8. self.db_password = "123456" # 用户密码
  9. self.db_charset = "utf8" # 数据库连接编码
  10. self.db_mincached = 20 # mincached : 启动时开启的闲置连接数量(缺省值 0 开始时不创建连接)
  11. self.db_maxcached = 20 # maxcached : 连接池中允许的闲置的最多连接数量(缺省值 0 代表不闲置连接池大小)
  12. self.db_maxshared = 30 # maxshared : 共享连接数允许的最大数量(缺省值 0 代表所有连接都是专用的)如果达到了最大数量,被请求为共享的连接将会被共享使用
  13. self.db_maxconnecyions = 100 # maxconnecyions : 创建连接池的最大数量(缺省值 0 代表不限制)
  14. self.db_blocking = True # blocking : 设置在连接池达到最大数量时的行为(缺省值 0 或 False 代表返回一个错误<toMany......> 其他代表阻塞直到连接数减少,连接被分配)
  15. self.db_maxusage = 0 # maxusage : 单个连接的最大允许复用次数(缺省值 0 或 False 代表不限制的复用).当达到最大数时,连接会自动重新连接(关闭和重新打开)
  16. self.db_setsession = None # setsession : 一个可选的SQL命令列表用于准备每个会话,如["set datestyle to german", ...]
  17. self.db_creator = pymysql # creator : 使用连接数据库的模块
  18. DB_CONFIG = db_config()
  19. class mq_config:
  20. def __init__(self):
  21. self.mq_ip = "192.168.1.200" # rabbitmq服务器ip地址
  22. self.mq_port = 5672 # 端口
  23. self.mq_user = "zx" # 用户名
  24. self.mq_password = "123456" # 用户密码
  25. self.mq_command_exchange_name = "command_ex" # 指令交换机名
  26. self.mq_statu_exchange_name = "statu_ex" # 状态交换机名
  27. self.mq_statu_exchange_keys = [[self.mq_statu_exchange_name, "dispatch_11_statu_port"],
  28. [self.mq_statu_exchange_name, "dispatch_12_statu_port"],
  29. [self.mq_statu_exchange_name, "dispatch_13_statu_port"],
  30. [self.mq_statu_exchange_name, "dispatch_14_statu_port"],
  31. [self.mq_statu_exchange_name, "dispatch_21_statu_port"],
  32. [self.mq_statu_exchange_name, "dispatch_22_statu_port"],
  33. [self.mq_statu_exchange_name, "dispatch_23_statu_port"],
  34. [self.mq_statu_exchange_name, "dispatch_24_statu_port"],
  35. [self.mq_statu_exchange_name, "dispatch_25_statu_port"],
  36. [self.mq_statu_exchange_name, "dispatch_31_statu_port"],
  37. [self.mq_statu_exchange_name, "dispatch_32_statu_port"]] # 状态交换机需要订阅的端口列表
  38. MQ_CONFIG = mq_config()
  39. class led_config:
  40. def __init__(self):
  41. self.led_list_all = {11: [{'ip': "192.168.1.169", 'port': 5005}],
  42. 12: [{'ip': "192.168.1.169", 'port': 5005}, {'ip': "192.168.1.169", 'port': 5005}],
  43. 13: [{'ip': "192.168.1.169", 'port': 5005}, {'ip': "192.168.1.169", 'port': 5005}],
  44. 14: [{'ip': "192.168.1.169", 'port': 5005}, {'ip': "192.168.1.169", 'port': 5005}],
  45. 21: [{'ip': "192.168.1.169", 'port': 5005}, {'ip': "192.168.1.169", 'port': 5005}],
  46. 22: [{'ip': "192.168.1.169", 'port': 5005}, {'ip': "192.168.1.169", 'port': 5005}],
  47. 23: [{'ip': "192.168.1.169", 'port': 5005}, {'ip': "192.168.1.169", 'port': 5005}],
  48. 24: [{'ip': "192.168.1.169", 'port': 5005}, {'ip': "192.168.1.169", 'port': 5005}],
  49. 25: [{'ip': "192.168.1.169", 'port': 5005}],
  50. 31: [{'ip': "192.168.1.164", 'port': 5005}, {'ip': "192.168.1.249", 'port': 5005}],
  51. 32: [{'ip': "192.168.1.169", 'port': 5005}]
  52. }
  53. # 区域编号,区域左上角X坐标,区域左上角Y坐标,区域宽度,区域高度
  54. self.area_list_all = {11: [{0: [0, 0, 170, 64], 1: [0, 0, 170, 64], 2: [0, 0, 170, 64]}],
  55. 12: [{0: [0, 0, 170, 64], 1: [0, 0, 170, 64], 2: [0, 0, 170, 64]},
  56. {0: [0, 0, 170, 64], 1: [0, 0, 170, 64], 2: [0, 0, 170, 64]}],
  57. 13: [{0: [0, 0, 170, 64], 1: [0, 0, 170, 64], 2: [0, 0, 170, 64]},
  58. {0: [0, 0, 170, 64], 1: [0, 0, 170, 64], 2: [0, 0, 170, 64]}],
  59. 14: [{0: [0, 0, 170, 64], 1: [0, 0, 170, 64], 2: [0, 0, 170, 64]},
  60. {0: [0, 0, 170, 64], 1: [0, 0, 170, 64], 2: [0, 0, 170, 64]}],
  61. 21: [{0: [0, 0, 170, 64], 1: [0, 0, 170, 64], 2: [0, 0, 170, 64]},
  62. {0: [0, 0, 170, 64], 1: [0, 0, 170, 64], 2: [0, 0, 170, 64]}],
  63. 22: [{0: [0, 0, 170, 64], 1: [0, 0, 170, 64], 2: [0, 0, 170, 64]},
  64. {0: [0, 0, 170, 64], 1: [0, 0, 170, 64], 2: [0, 0, 170, 64]}],
  65. 23: [{0: [0, 0, 170, 64], 1: [0, 0, 170, 64], 2: [0, 0, 170, 64]},
  66. {0: [0, 0, 170, 64], 1: [0, 0, 170, 64], 2: [0, 0, 170, 64]}],
  67. 24: [{0: [0, 0, 170, 64], 1: [0, 0, 170, 64], 2: [0, 0, 170, 64]},
  68. {0: [0, 0, 170, 64], 1: [0, 0, 170, 64], 2: [0, 0, 170, 64]}],
  69. 25: [{0: [0, 0, 170, 64], 1: [0, 0, 170, 64], 2: [0, 0, 170, 64]}],
  70. 31: [{0: [0, 0, 170, 64], 1: [0, 0, 170, 64], 2: [0, 0, 170, 64]},
  71. {0: [0, 0, 170, 64], 1: [0, 0, 170, 64], 2: [0, 0, 170, 64]}],
  72. 32: [{0: [0, 0, 170, 64], 1: [0, 0, 170, 64], 2: [0, 0, 170, 64]}]
  73. }
  74. self.unit = 31
  75. self.channel = 2
  76. # self.led_communication = self.led_list_all[self.unit]
  77. # self.area_list = self.area_list_all[self.unit]
  78. LED_CONFIG = led_config()