示例#1
0
    def get(self):
        try:
            self.get_init('deviceId')

            commands = [
                region_api.getDeviceInfo(self.deviceId),  #查设备信息,是否置顶
                region_api.getTaggedDevices(
                    self.user_id, '已关注',
                    filter_device_id=self.deviceId),  #查是否已关注
                region_api.getDevicePath(self.deviceId),  #查区域架构路径
                model_api.getDeviceTemplate(),  #查询设备基础模板
            ]

            msg = {'Type': 'BatchReadReq', 'Commands': commands}
            data = yield self.genResult('dm', msg, self.batch_response)

            props = data['NSDevicesTemplate']['Props']
            map_msg = model_api.getMapOptions(props)
            if map_msg is not None:
                map_options = yield self.genResult('dm', map_msg,
                                                   self.parse_dict_man)

                if map_options is None: return
                data['NSDevicesTemplate'][
                    'Props'] = model_api.updateMapOptionsForProperties(
                        props, map_options)

            self.send(self.SUCCESS, data)
        except HandlerError as e:
            self._send(e.json_msg)
示例#2
0
    def get(self):
        try:
            self.get_init()

            keys = {
                'model_cluster_state_template': 'ClusterState',
                'model_cluster_node_state_template': 'DataModelState'
            }
            path = self.get_request_path()

            props = yield self.genResult(
                'dm', model_api.getModelClusterTemplate(keys[path]),
                self.dict_model)

            msg = model_api.getMapOptions(props)
            if msg:
                map_options = yield self.genResult('dm', msg,
                                                   self.parse_dict_man)
                props = model_api.updateMapOptionsForProperties(
                    props, map_options)

            self.send(self.SUCCESS, {"ModelTemplate": {'Props': props}})

        except HandlerError as e:
            self._send(e.json_msg)
示例#3
0
    def get(self):
        try:
            self.get_init('categroy')

            if self.categroy not in ('NSDevices', 'NSDevicesAlarmInfo', 'NSDevicesVarInfo', \
                    'NSDeviceFlowChart', 'NSDutyCard', 'NSDeviceUIFault', \
                    'NSDeviceUIRunState', 'NSDeviceUIParam', 'NSDeviceUIOverview'):
                raise HandlerError(
                    self.rsp_code['params_error'],
                    "categroy %s does not support" % self.categroy)

            props = yield self.genResult('dm', model_api.getDeviceTemplate(),
                                         self.device_template)

            msg = model_api.getMapOptions(props)
            if msg:
                map_options = yield self.genResult('dm', msg,
                                                   self.parse_dict_man)

                props = model_api.updateMapOptionsForProperties(
                    props, map_options)

            self.send(self.SUCCESS,
                      {'%sTemplate' % self.categroy: {
                          'Props': props
                      }})
        except HandlerError as e:
            self._send(e.json_msg)
示例#4
0
    def get(self):
        try:
            self.get_init()

            props = yield self.genResult('dm', model_api.getUserTemplate(),
                                         self.user_template)

            msg = model_api.getMapOptions(props)
            if msg:
                map_options = yield self.genResult('dm', msg,
                                                   self.parse_dict_man)
                props = model_api.updateMapOptionsForProperties(
                    props, map_options)

            self.send(self.SUCCESS, {'NSUsersTemplate': {'Props': props}})
        except HandlerError as e:
            self._send(e.json_msg)
示例#5
0
    def get(self):
        try:
            self.get_init()

            keys = {
                'model_template': 'DataModel-Self-Properties',
                'system_model_node_template': 'DataNode-Self-Properties',
                'custom_model_node_template': 'DataNode-Self-Properties',
                'model_property_template': 'DataNode-Property-Properties',
                'model_nodeindex_template': 'DataNode-Index-Properties'
            }
            path = self.get_request_path()

            props = yield self.genResult(
                'dm', model_api.getModelTemplate(keys[path]), self.dict_model)
            msg = model_api.getMapOptions(props)
            if msg:
                map_options = yield self.genResult('dm', msg,
                                                   self.parse_dict_man)
                props = model_api.updateMapOptionsForProperties(
                    props, map_options)

            path = self.get_request_path()
            if path.endswith('model_node_template'):
                for p in props:
                    if p['Form']['Type'] != 'DataNodePicker': continue

                    if path.startswith('system'):
                        p['Form']['Type'] = 'SystemDataNodePicker'
                    elif path.startswith('custom'):
                        p['Form']['Type'] = 'CustomDataNodePicker'

            self.send(self.SUCCESS, {"ModelTemplate": {'Props': props}})

        except HandlerError as e:
            self._send(e.json_msg)
示例#6
0
    def get(self):
        try:
            self.get_init('deviceId', 'categroy')

            if self.categroy not in ('NSDevices', 'NSDevicesDriver', 'NSDevicesAlarmInfo', 'NSDevicesVarInfo', \
                    'NSDeviceFlowChart', 'NSDutyCard', 'NSDeviceUIFault', \
                    'NSDeviceUIRunState', 'NSDeviceUIParam', 'NSDeviceUIOverview'):
                raise HandlerError(
                    self.rsp_code['params_error'],
                    "categroy %s does not support" % self.categroy)

            tree_filter = '%s[]' % self.categroy
            if self.categroy == 'NSDevicesDriver':
                tree_filter = 'NSDevicesDriver[].NSDriverLogicDevice[].{NSDevicesCommunicateParameter[],NSDevicesCommunicateDataBlock[].NSDevicesCommunicateDataBlockParameter[]}'

            if self.categroy != 'NSDevices':
                tree_filter = 'NSDevices[].%s' % tree_filter

            msg = {
                "Type": "GetBOTreeReq",
                "DataModelName": "s_DeviceMan",
                "BOName": "NSDevices",
                "WhereType": "CONDITION",
                "Where": "DeviceID==\"%s\"" % self.deviceId,
                "TreeFilter": tree_filter,
            }
            device_data = yield self.genResult('dm', msg, self.parse_device)

            data = {}
            if self.categroy == 'NSDevices':
                data['NSDevices'] = [{
                    "ParameterName": k,
                    "ParameterValue": v
                } for k, v in device_data.items()]
            else:
                data['_ID'] = device_data.get('_ID')
                data[self.categroy] = device_data.get(self.categroy)
                if data.get(self.categroy) is None: data[self.categroy] = []
                elif self.categroy == 'NSDevicesVarInfo':
                    for b in data[self.categroy]:
                        b['RelatedVar'] = b.get('VarName')

            if self.categroy == 'NSDevicesDriver':
                if not data.get('NSDevicesDriver'):
                    data['NSDriverTemplate'] = {'Props': []}
                    self.send(self.SUCCESS, data)
                    return
                else:
                    msg = model_api.getDeviceDriverTemplates(
                        self.get_driver_type_list(data.get('NSDevicesDriver')))
                    data['NSDriverTemplate'] = yield self.genResult(
                        'dm', msg, self.parse_global_conf)
            else:
                props = yield self.genResult('dm',
                                             model_api.getDeviceTemplate(),
                                             self.device_template)

                msg = model_api.getMapOptions(props)
                if msg:
                    map_options = yield self.genResult('dm', msg,
                                                       self.parse_dict_man)
                    props = model_api.updateMapOptionsForProperties(
                        props, map_options)

                data['%sTemplate' % self.categroy] = {'Props': props}

            self.send(self.SUCCESS, data)

        except HandlerError as e:
            self._send(e.json_msg)
示例#7
0
 def update_dict_options(self, oMsg, props):
     return model_api.updateMapOptionsForProperties(props, oMsg['BOS'])