} # ActivityDuration is configured to process both types of activity fn_activity = bif.ActivityDuration( table_name=activity_name, activity_codes=['maintenance', 'break'], activity_duration=['maintenance_duration', 'break_duration']) # ActivityDuration is configured to eliminate overlaps across both types of # activity. Only one type of activity of any type can take place at any # point in time. fn_activity.remove_gaps = 'across_all' # configure ActivityDuration to entity.drop_tables(recreate=True) entity = EntityType( entity_name, db, Column('temp', Float()), Column('pressure', Float()), Column('company_code', String(50)), Column('category_code', String(5)), bif.EntityDataGenerator(parameters=sim_parameters, data_item='is_generated'), bif.ShiftCalendar(shift_definition=shift_dict, period_start_date='shift_start_date', period_end_date='shift_end_date', shift_day='shift_day', shift_id='shift_id'), bif.SCDLookup(table_name=scd_name, output_item='crew'), fn_activity, **{ '_timestamp': 'evt_timestamp', '_db_schema': db_schema })
# create entity types and execute the calc pipeline to get some test data data_sources = [] start_device_id = 10000 for (data_source_name, metric_name) in [child1, child2]: sim_parameters['start_entity_id'] = start_device_id entity = EntityType( data_source_name, db, Column(metric_name, Float()), bif.EntityDataGenerator(parameters=sim_parameters, data_item='is_generated'), **{ '_timestamp': 'evt_timestamp', '_db_schema': db_schema }) dim = '%s_dim' % data_source_name entity.drop_tables([dim]) entity.make_dimension( dim, # build name automatically Column('work_area', String(50))) entity.exec_local_pipeline() data_sources.append(entity) start_device_id += 10000 ''' This is what the generated data looks like: Time series data for temperature: DEVICEID EVT_TIMESTAMP DEVICETYPE LOGICALINTERFACE_ID EVENTTYPE FORMAT UPDATED_UTC TEMPERATURE 10001 2019-08-22-21.18.10.884128 temp_data ep 21.602888736326957 10017 2019-08-22-21.23.10.884128 temp_data ye 23.517696994037884