Scheduled App- Back End

Back End Scheduled App: Overview

Introduction

This document will explain what a scheduled app is and how it works.

A Back End scheduled app, or polling app, is an app that runs continuously on the server for the duration of the active data stream. Because it is constantly fetching stream data, it is within the real-time app family.

A Back End scheduled app returns real-time, streaming data set to a user-defined interval.

The function must receive three arguments: event, API, and cache.

NOTE: In order to view videos in high resolution, please click on the Settings icon in YouTube, then select the highest resolution available.

Use Cases:

Typical use cases for a scheduled app are when your business logic requires real-time data at regular intervals greater than 1 second. Because most uses of real-time data do not require fine granularity, the majority of real-time applications are expected to be scheduled apps.

  • I require real-time data

  • I require regularly sampled data with interval > 1s

  • I require the app to be attached to the asset stream

  • I do not require the app to be invoked from a front-end app

  • I do not require the app to be triggered

If you require real-time data at one second intervals (or the next available measurement), you should use a instead.

Example:

The end-user is looking for equipment parameters or measurements where data is NOT changing rapidly or there is no operational requirement to have one second interval data. For example, monitoring fluid pressures, pump speeds, or other non-critical alerts. In principal, anything that does not immediately impact real-time operational decision making should be a scheduled app.

Usage:

Scheduled Apps only run on active streams, for example completion.wits or wireline.wits

Sample event for wits:

{
  "_id": "6144bd4c32c8a7202b8b680a",
  "version": 1,
  "provider": "corva",
  "collection": "wits",
  "timestamp": 1436182260,
  "asset_id": 20173768,
  "company_id": 196,
  "app": "corva.wits-historical-import",
  "data_raw": {
    "hook_load": -999.25,
    "standpipe_pressure": -999.25
  },
  "metadata": {
    "drillstring": "6144b6b152c0a12241cb4f60",
    "casing": null,
    "mud": "6144b9f836cfd72a42a97542",
    "cuttings": null,
    "surface-equipment": "6144b9e46764c92dff879d33",
    "actual_survey": "6144ba975140c7244f842905",
    "plan_survey": null
  },
  "data": {
    "entry_at": 1436182260,
    "mud g/l alarm state": 0,
    "total mud volume": -999.25,
    "trip tank mud volume": -999.25,
    "line wear": 8978,
    "totalpumpdisplacement": 0,
    "on bottom hours": 48.7,
    "circulating hours": 79.5,
    "tool face": 1234,
    "inclination": 2.9,
    "azimuth": 154.06,
    "h2s": 1,
    "nitrogen pressure in": 1,
    "nitrogen volume in": 0.9,
    "hydrocarbon flow": 0,
    "mwd temperature": -999.25,
    "mwd vibration count": -999.25,
    "mwd general variable 1": -999.25,
    "condensate out": 0.84,
    "mwd general variable 3": -999.25,
    "mwd general variable 4": -999.25,
    "mwd vibration xy gamma": -999.25,
    "mwd vibration z gamma": -999.25,
    "over pull": 0,
    "fill strokes": 0,
    "total fill strokes": 0,
    "mwd general variable 7": -999.25,
    "mwd general variable 8": -999.25,
    "mwd general variable 9": -999.25,
    "mwd general variable 10": -999.25,
    "min wob": 0,
    "surface stick slip index": -999.25,
    "mwd dynamic inc": 0,
    "mwd dynamic azi": 0,
    "mwd vibration xyz gamma": -999.25,
    "cement fluid temp": -999.25,
    "mwd vibration xyz": -999.25,
    "autodriller status 2 uw": -999.25,
    "nitrogen volume out": 0.5,
    "autodriller status 2 lw": -999.25,
    "trip tank 1 low threshold": 0,
    "trip tank 1 high threshold": 0,
    "total gas return": 1,
    "trip tank 2 low threshold": 0,
    "trip tank 2 high threshold": 0,
    "sensor depth": 0,
    "bit rpm": -999.25,
    "pvt total mud gain/loss": -999.25,
    "mwd general variable 2": -999.25,
    "wits lag depth": 0,
    "pason lag depth": 6500.1,
    "autodriller drum ticks": -999.25,
    "flow data air (cmf)": 0,
    "flow data pressure (psig)": 0,
    "flow data temp (f)": 68,
    "tts weight on bit": 0,
    "drilling activity": 0,
    "min tts weight on bit": 0,
    "trip speed": -999.25,
    "pump 4 total strokes": 0,
    "autodriller status": 0,
    "autodriller sensitivity": 0,
    "convertible torque": -999.25,
    "min convertible torque": -999.25,
    "mwd general variable 5": -999.25,
    "mwd general variable 6": -999.25,
    "porosity 2 depth": 432,
    "formation density depth": 0.51,
    "min pressure": -999.25,
    "min hook load": -999.25,
    "min torque": -999.25,
    "min rpm": -999.25,
    "mwd general variable 0": -999.25,
    "relative mse": -999.25,
    "motor rpm": 0,
    "porosity 1 depth": 0.87,
    "autodriller wob": -999.25,
    "autodriller brake pos": -999.25,
    "autodriller diff press": -999.25,
    "autodriller status uw": -999.25,
    "autodriller status lw": -999.25,
    "autodriller off bottom rop limit": 0,
    "autodriller ticks per depth": -999.25,
    "pvt mud tanks included": -999.25,
    "pvt monitor mud gain/loss": -999.25,
    "pvt mud g/l threshold": 0,
    "trip tank 1 refill status": -999.25,
    "flow 1 g/l threshold": 0,
    "xy accel_ severity level": -999.25,
    "z accel_ severity level": -999.25,
    "trip tank fill": -999.25,
    "trip tank accum": -999.25,
    "rate of penetration": 0,
    "time of penetration": 0,
    "memos": "",
    "bit_depth": 0,
    "block_height": 25.4,
    "hole_depth": 0,
    "diff_press": 0,
    "hook_load": 0,
    "rop": 0,
    "rotary_rpm": 0,
    "pump_spm_1": 0,
    "pump_spm_2": 0,
    "standpipe_pressure": 0,
    "rotary_torque": 0,
    "pump_spm_total": -999.25,
    "mud_flow_in": 0,
    "strks_total": 0,
    "strks_pump_3": 0,
    "weight_on_bit": 0,
    "strks_pump_1": 0,
    "strks_pump_2": 0,
    "ad_rop_setpoint": 0,
    "ad_wob_setpoint": 0,
    "gravity_tool_face": 26,
    "magnetic_tool_face": 234,
    "ad_diff_press_setpoint": 0,
    "gamma_ray": 0,
    "true_vertical_depth": 0,
    "state": "In Slips"
  }
}

Sample event for wits

Sample event for completion.wits:

{
  "_id": "614ca933484e646f3f48b026",
  "version": 1,
  "provider": "corva",
  "collection": "completion.wits",
  "timestamp": 1446849214,
  "asset_id": 20173768,
  "company_id": 196,
  "stage_number": 1,
  "data": {
    "timestamp": 1446849214,
    "is_valid": true,
    "wellhead_pressure": 3956,
    "slurry_flow_rate_in": 0,
    "elapsed_time": 0,
    "clean_flow_rate_in": 0,
    "total_clean_volume_in": 0,
    "total_slurry_volume_in": 0,
    "total_chemical_rate_in": 0,
    "total_friction_reducer": 0,
    "total_proppant_concentration": 0,
    "total_proppant_mass": 0,
    "bottomhole_proppant_concentration": 0,
    "hydrostatic_pressure": 3217.3366382377926,
    "inverse_hydrostatic_pressure": 0.0003108160918304534,
    "backside_pressure": 7,
    "enzyme_breaker": 0,
    "scale_inhibitor": 0,
    "surfactant": 0,
    "friction_reducer": 0,
    "friction_reducer_extra": 0,
    "cross_linker": 0,
    "acid": 0,
    "gel": 0,
    "ph_adjusting_agent": 0,
    "accelerator": 0,
    "fluid_loss": 0,
    "ploymer_plug": 0,
    "acid_inhibitor": 0,
    "acid_retarder": 0,
    "emulsifier": 0,
    "clay_stabilizer": 0,
    "non_emulsifier": 0,
    "fines_suspender": 0,
    "anti_sludge": 0,
    "iron_control": 0,
    "oxygen_scavenger": 0,
    "mutual_solvent": 0,
    "corrosion_inhibitor": 0,
    "paraffin_control": 0,
    "biocide": 0,
    "instant_crosslinker": 0,
    "delayed_crosslinker": 0,
    "liquid_breaker": 0,
    "powder_breaker": 0,
    "divertor": 0,
    "powder_gel": 0,
    "powder_friction_reducer": 0,
    "powder_enzyme_breaker": 0,
    "proppant_1_concentration": 0,
    "proppant_2_concentration": 0,
    "tr press deriv": 7.36,
    "slur rate2": 1.1,
    "prop con2": 0,
    "bh prop con": 0,
    "tmt 100 mesh sand": 0,
    "tmt 40/70 white": 0,
    "an press 1h": 7,
    "proppant_1_mass": 0,
    "pumpside_pressure": 1932,
    "extra_clean_fluid": 0
  }
}

Sample event for completion.wits

Sample event for wireline.wits

{
       "_id":"5f161be7de7b936052e8bd5e",
       "timestamp":1574279322,
       "version":1,
       "provider":"corva",
       "collection":"wireline.wits",
       "asset_id":123456,
       "company_id":1,
       "stage_number":2,
       "app":"corva.app",
       "data":{
          "c_006":-0.5522,
          "c_007":-999.25,
          "current":0,
          "voltage":0,
          "line_speed":0.05,
          "elapsed_time":1119.9359,
          "line_tension":320.5558,
          "measured_depth":274.7967,
          "casing_collar_locator":-0.08,
          "state":"Unclassified",
          "wellbore_orientation":"Vertical"
   	}
	}

Sample event for wireline.wits

First, a scheduled data event occurs that returns a start time, end time, asset ID, company ID, and collection name.

  • Start time: the timestamp from the previous value

  • End time: the timestamp from the next value

  • Asset ID: the unique well name/number

  • Company ID: the company with access to the asset

  • Collection name: the name of the data stream, eg completion.wits

Additional parameters can be passed via the scheduled data event such as an external API URL/KEY or well ID.

Then, these parameters are passed to an API query to fetch and return the data.

Further logic can then be applied and the data <stored in a collection??>. The app will run continuously as long as the data stream is active.

A scheduled app can either use data time (the time associated with the particular measurement; eg, whenever the data comes from the provider) or natural time (clock time, regardless of when the data arrives).

What’s Next

Build a Stream App with Python Workflow

More Resources:

Creating Back End Scheduled App Template on Your Local Machine