def get(self): args = equipgroup_parser.parse_args() session = Session() if args['iftree']: treejson = {'name': 'Induction Motor Monitoring Platform', 'children': []} for motor in session.query(Motor.id, Motor.name).all(): treejson['children'].append({'name': motor.name, 'children': []}) for bearing in session.query(Bearing.name).filter_by(motor_id=motor.id).all(): treejson['children'][-1]['children'].append({'name': bearing.name}) for rotor in session.query(Rotor.name).filter_by(motor_id=motor.id).all(): treejson['children'][-1]['children'].append({'name': rotor.name}) for stator in session.query(Stator.name).filter_by(motor_id=motor.id).all(): treejson['children'][-1]['children'].append({'name': stator.name}) session.close() return treejson, 200 else: session = Session() motors = session. \ query(Motor). \ options(joinedload(Motor.rotors), joinedload(Motor.stators), joinedload(Motor.bearings)). \ all() data = EquipGroupSchema().dump(motors, many=True) session.close() return data
def patch(self, id): args = parser.parse_args() session = Session() session.query(Bearing).filter(Bearing.id == id).update({'lr_time': args['lr_time']}) Session.commit() session.close() return {'message': 'Success'}
def patch(self, id): args = motor_parser.parse_args() session = Session() session.query(Motor).filter(Motor.id == id).update( {'lr_time': args['lr_time']}) session.commit() session.close() return {'message': 'Success'}
def get(self, id): args = parser.parse_args() if args['info']: session = Session() rotors = session.query( Rotor.inner_diameter, Rotor.length, Rotor.outer_diameter, Rotor.slot_number).filter_by(motor_id=id).all() return RotorSchema().dump(rotors, many=True) else: session = Session() rotors = Session.query(Rotor).filter_by(motor_id=id).all() session.close() return RotorSchema().dump(rotors, many=True)
def get(self, id): args = parser.parse_args() if args['info']: session = Session() bearings = session.query(Bearing.inner_race_diameter, Bearing.inner_race_width, Bearing.outter_race_diameter, Bearing.outter_race_width, Bearing.roller_diameter, Bearing.roller_number, Bearing.contact_angle).filter_by(motor_id=id).all() return BearingSchema().dump(bearings, many=True) else: session = Session() bearings = session.query(Bearing).filter_by(motor_id=id).all() session.close() return BearingSchema().dump(bearings, many=True)
def get(self, id): args = motor_parser.parse_args() if args['info']: session = Session() motor = session.query(Motor.phase_number, Motor.pole_pairs_number, Motor.turn_number, Motor.rated_voltage, Motor.rated_speed).filter_by(id=id).one() return MotorSchema().dump(motor) else: session = Session() motor = session.query(Motor.id, Motor.name, Motor.health_indicator, Motor.lr_time, Motor.sn, Motor.memo, Motor.statu).filter_by(id=id).one() session.close() return MotorSchema().dump(motor)
def get(self, id): session = Session() bearings = session.query(Bearing.inner_race_diameter, Bearing.inner_race_width, Bearing.outter_race_diameter, Bearing.outter_race_width, Bearing.roller_diameter, Bearing.roller_number, Bearing.contact_angle).filter_by(id=id).one() return BearingSchema().dump(bearings)
def get(self, id): session = Session() rotors = session.query(Rotor.inner_diameter, Rotor.length, Rotor.outer_diameter, Rotor.slot_number).filter_by(id=id).one() session.close() return RotorSchema().dump(rotors)
def get(self, id): session = Session() data = session.query(Motor.name, WarningLog.cr_time, WarningLog.description, WarningLog.severity). \ join(Motor). \ filter(WarningLog.motor_id == id).all() session.close() return WarningSchema().dump(data, many=True).data
def get(self, id): phase = self.model_factory.model(motor_id=id) args = phase_parser.parse_args() if args['newest'] == True: session = Session() data = session.query(phase.wave).order_by(phase.id.desc()).first() session.close() return PhaseSchema(only=('wave', )).dump(data) elif args['pack_id']: session = Session() data = session.query( phase.wave).filter_by(pack_id=args['pack_id']).first() session.close() return PhaseSchema(only=('wave', )).dump(data) else: return 400
def get(self, id): session = Session() motor = session.query(Motor). \ options(joinedload(Motor.rotors), joinedload(Motor.stators), joinedload(Motor.bearings)). \ filter_by(id=id). \ one() session.close() return EquipGroupSchema().dump(motor)[0]
def get(self): args = motor_parser.parse_args() if args['group_by'] == 'statu': data = retrieve_model.get_statu_statistic() return MotorStatuStatisticSchema().dump(data, many=False) elif args['group_by'] == 'comps': data = retrieve_model.get_comp_statistic() return MotorCompStatisticSchema().dump(data, many=True) else: session = Session() motors = session.query(Motor.name, Motor.sn, Motor.statu, Motor.lr_time, Motor.id, Motor.health_indicator, User.name.label('admin')). \ join(User).all() session.close() return MotorSchema().dump(motors, many=True)
def get(self, id): uphase = Uphase.model(motor_id=id) vphase = Vphase.model(motor_id=id) wphase = Wphase.model(motor_id=id) args = phase_parser.parse_args() session = Session() data = \ session.query(uphase.wave.label('u'), vphase.wave.label('v'), wphase.wave.label('w')). \ join(vphase, vphase.pack_id == uphase.pack_id). \ join(wphase, wphase.pack_id == uphase.pack_id). \ filter_by(pack_id=args['pack_id']).first() session.close() return PhaseSchema(only=('u', 'v', 'w')).dump(data)
def get(self, id, pack_id): uphase = Uphase.model(motor_id=id) vphase = Vphase.model(motor_id=id) wphase = Wphase.model(motor_id=id) session = Session() data = session.query(uphase.wave.label('u'), vphase.wave.label('v'), wphase.wave.label('w')). \ join(vphase, vphase.pack_id == uphase.pack_id). \ join(wphase, wphase.pack_id == uphase.pack_id). \ filter_by(pack_id=pack_id).one() session.close() data = data._asdict() for key in ['u', 'v', 'w']: data[key] = np.fromstring(data[key], dtype=np.float32) data[key + 'envelope'] = np.abs( signal.hilbert(data[key])[1024:1024 + 4096]) data[key + 'fft'] = np.around(fftransform( signal.detrend(data[key + 'envelope'])), decimals=3) data[key] = data[key][1024:1024 + 4096] return EnvelopeSchema().dump(data)