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)
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)
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)
def get(self): try: self.get_init('roleId') commands = [ sysconf_api.roleInfo(self.roleId), model_api.getRoleTemplate() ] role_info, template_props = yield self.genResult('dm', {'Type': 'BatchReadReq', 'Commands': commands}, self.parse_batch_response) # 角色模板 oMsg = yield self.genResult('dm', model_api.getMapOptions(template_props)) template_props = self.update_dict_options(oMsg, template_props) # 角色区域、组织架构路径获取 commands = [] if role_info.get('Area'): areas = role_info.get('Area').rstrip(';').split(';') commands.append(region_api.getNodePath(areas)) else: role_info['Area'] = [] if role_info.get('Organization'): organizations = role_info.get('Organization').rstrip(';').split(';') commands.append(dept_api.getNodePath(organizations)) else: role_info['Organization'] = [] if len(commands) > 0: oMsg = yield self.genResult('dm', {'Type': 'BatchReadReq', 'Commands': commands}) role_info = self.parse_path_response(oMsg, role_info) self.send(self.SUCCESS, {'Role': role_info, 'RoleTemplate': {'Props': template_props}}) except HandlerError as e: self._send(e.json_msg)
def get(self): try: self.get_init() props = yield self.genResult('dm', model_api.getRoleTemplate(), self.data_model) oMsg = yield self.genResult('dm', model_api.getMapOptions(props)) props = self.update_dict_options(oMsg, props) path = self.get_request_path() if path.startswith('role_list'): pIndexs = [] i = 0 for p in props: try: f = p.get('Form') if not f: pIndexs.append(i) continue t = f['Type'] if t.endswith('Picker'): pIndexs.append(i) finally: i += 1 pIndexs.reverse() for pi in pIndexs: props.pop(int(pi)) self.send(self.SUCCESS, {'RoleTemplate': {'Props': props}}) except HandlerError as e: self._send(e.json_msg)
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)
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)
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)