123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- # coding=utf-8
- import os
- from base import init_env
- init_env(True)
- from apps.web.device.models import DeviceCommand, DeviceCommandParam
- MQTT_HOSTNAME = os.environ['MQTT_HOSTNAME']
- MQTT_PORT = os.environ['MQTT_PORT']
- MQTT_PORT_SECURITY = os.environ['MQTT_PORT_SECURITY']
- def init_201_cmd():
- DeviceCommand(
- common=True,
- description=u"查询设备",
- cmd=201
- ).save()
- def init_202_turn_on_debug():
- param = DeviceCommandParam(
- description=u"开关打开",
- key="debug",
- default="true"
- )
- cmd = DeviceCommand(
- common=True,
- description=u"打开调试",
- cmd=202
- )
- cmd.params = [param]
- cmd.save()
- def init_202_turn_off_debug():
- param = DeviceCommandParam(
- description=u"开关关闭",
- key="debug",
- default="false"
- )
- cmd = DeviceCommand(
- common=True,
- description=u"关闭调试",
- cmd=202
- )
- cmd.params = [param]
- cmd.save()
- def init_202_update_driver():
- param = DeviceCommandParam(
- description=u"驱动地址",
- key="driver_set",
- default='{"driver_url": "http://121.43.232.118/uploaded/version/drivers/task/*/default.driver"}',
- allow_change=True
- )
- cmd = DeviceCommand(
- common=True,
- description=u"升级驱动",
- cmd=202
- )
- cmd.params = [param]
- cmd.save()
- def init_202_update_bin():
- param = DeviceCommandParam(
- description=u"版本地址",
- key="ota_set",
- default='{"fw_url": "http://121.43.232.118/uploaded/version/2g/*.bin"}',
- allow_change=True
- )
- cmd = DeviceCommand(
- common=True,
- description=u"升级版本",
- cmd=202
- )
- cmd.params = [param]
- cmd.save()
- def init_202_restart_83():
- param = DeviceCommandParam(
- description=u"重启IP",
- key="addr_set",
- default='{"ip1": %s, "port1": %s}' % (MQTT_HOSTNAME, MQTT_PORT)
- )
- cmd = DeviceCommand(
- common=True,
- description=u"83重启",
- cmd=202
- )
- cmd.params = [param]
- cmd.save()
- def init_202_restart_84():
- param = DeviceCommandParam(
- description=u"重启IP",
- key="addr_set",
- default='{"ip1": %s, "port1": %s}' % (MQTT_HOSTNAME, MQTT_PORT_SECURITY)
- )
- cmd = DeviceCommand(
- common=True,
- description=u"84重启",
- cmd=202
- )
- cmd.params = [param]
- cmd.save()
- def init_210_serial_test():
- param1 = DeviceCommandParam(
- description=u"功能码",
- key="funCode",
- default='01',
- allow_change=True
- )
- param2 = DeviceCommandParam(
- description=u"数据域",
- key="data",
- default='00',
- allow_change=True
- )
- cmd = DeviceCommand(
- common=True,
- description=u"210串口指令",
- cmd=210
- )
- cmd.params = [param1, param2]
- cmd.save()
- if __name__ == '__main__':
- init_201_cmd()
- init_202_restart_83()
- init_202_restart_84()
- init_202_turn_off_debug()
- init_202_turn_on_debug()
- init_202_update_bin()
- init_202_update_driver()
- init_210_serial_test()
|