Sedona

sys::App


sys::Obj
  sys::Virtual
    sys::Component
      sys::App

public class App [palette=false, niagaraIcon="module://icons/x16/database.png"]

App encapsulates an application database which includes the list of available Types, the Component instances, their configuration, and the Links.


appName

public inline property Buf appName [asStr, config, max=16]

Name of the app, up to 15 ASCII chars long

comps

public Component[] comps

List of application component indexed by id (may be sparse with null items).

compsLen

public int compsLen

Size of the components array

cycleCount

public long cycleCount

This counter is incremented at the start of each engine cycle

deviceName

public inline property Buf deviceName [asStr, config, max=16]

Logical name for the device, up to 15 ASCII chars long

guardTime

public property int guardTime [config, unit="millisecond"]

Time before the end of the scan period in which no new services work should be started in order to allow work in progress to finish before the end of scan.

hibernationResetsSteadyState

public property bool hibernationResetsSteadyState [config]

If true, when the App returns from hibernation then the steady state will be reset and the App will not return to steady state until timeToSteadyState has elapsed.

kitIdMap

public int[] kitIdMap

lastEndWork

public long lastEndWork

Timestamp of end of service's work (also start of sleep time). This timestamp corresponds to the PREVIOUS scan.

    lastEndWork - lastStartWork = work time of previous scan
lastStartExec

public long lastStartExec

Cache of the timestamp of the start of the component tree execution of the PREVIOUS scan. It is intended that that timing statistics to be computed within the execute method of a component dropped into the component tree, so we need to cache the start of the last component tree execution. Also marks the time that sleep ends on previous scan.

    lastStartWork - lastStartExec = execution time of previous scan
lastStartWork

public long lastStartWork

Timestamp of start of service work (also marks the end of component tree execution). If timing statistics computed during component tree execution, this timestamp corresponds to the PREVIOUS scan.

    lastEndWork - lastStartWork = work time of previous scan
log

public static const define Log log

Application level logging

newStartExec

public long newStartExec

End of previous scan sleep time is also the start of a new component tree execution This marks start of he CURRENT scan, such that:

    newStartExec - lastStartExec = scan time of PREVIOUS scan
platform

public PlatformService platform

PlatformService installed in this application

scanPeriod

public property int scanPeriod [config, unit="millisecond"]

Scan cycle period in milliseconds.

services

public Service services

Linked list of services

timeToSteadyState

public property int timeToSteadyState [config, unit="millisecond"]

Time from app start to steady state, in milliseconds.

watches

public inline Watch[] watches

This array references the active watches by referencing the application specific subclasses currently open.

add

public Component add(Component parent, Str name, Type t)

Add a component to the application. Return the new Component on success, null on failure.

addLink

public Link addLink(Component from, Slot fromSlot, Component to, Slot toSlot)

Add a new Link into the application by registering it in both the "to" and "from" component's linked-list of Links. Return the new Link or null on error.

cleanupApp

public void cleanupApp()

Free all the dynamic memory associated with this application.

closeWatch

public void closeWatch(Watch watch)

Close the specific watch by freeing its id to be used again and setting its closed field to false.

getFirstChildOfType

public Component getFirstChildOfType(Component parent, Type t)

Gets first child component of a given type. Returns null if no objects found, otherwise returns a Component

getNextSiblingOfType

public Component getNextSiblingOfType(Component component, Type t)

Gets next sibling of a component that is of type t. Returns null if end of sibling list is reached without finding one.

hibernate

public action void hibernate() [confirmRequired]

Action to request hibernation. Current execute loop will complete and all services will get a chance to work before hibernation occurs

initApp

public bool initApp(int initCompsLen)

Prepare the applications data structures to begin configuration.

initWatches

public void initWatches(Watch[] subclasses)

Each service which uses watches, should call this method on startup with it's service specific array of Watch subclasses.

isRunning

public bool isRunning()

Is the application currently running

isSteadyState

public bool isSteadyState()

Has the application reached steady state (as defined by timeToSteadyState)

load

public int load()

Load the application from persistent storage

loadApp

public int loadApp(InStream in)

Load the app from a binary format input stream. Return 0 on success or non-zero on error.

loadSchema

public bool loadSchema(InStream in)

Check that the schema on the input stream matches the schema of the current runtime.

In this version, we allow the app to depend on fewer kits than the scode, as long as all the app's kits are in the scode.

lookup

public Component lookup(int id)

Lookup a component by id or null.

lookupLink

public Link lookupLink(int fromCompId, int fromSlotId, int toCompId, int toSlotId)

Find a link with the specified from and to ids or return null if not found.

lookupService

public Service lookupService(Type type)

Lookup a service by type (or base type). Return null if there are no registered services which implement the specified type.

maxId

public int maxId()

Get the maximum component id used by the application.

openWatch

public Watch openWatch(Watch[] subclasses)

Allocate a watch for a service using watches. The service should pass in its service specific array of Watch subclasses. If a watch is opened then it is reserved, its closed field is set to false, and the subclass instance is returned. If all the watches are currently open, then return null.

quit

public action void quit() [confirmRequired]

Save the application and then exit the main loop.

reboot

public action void reboot() [confirmRequired]

Action to invoke Platform.reboot.

remove

public bool remove(Component c)

Remove the specified component and free it's memory. This method automatically recursively removes any children of the component first. Return true on success, false on failure.

removeLink

public bool removeLink(Link link)

Remove a Link from the application by unregistering it from both the "to" and "from" component's list linked of Links. Return true on success, false on failure.

restart

public action void restart() [confirmRequired]

Action to invoke Platform.restart.

resumeApp

public int resumeApp()

Run this application - right now this is a simple round robin execution.

runApp

public int runApp()

Run this application - right now this is a simple round robin execution.

save

public action void save()

Save the application back to persistent storage

saveApp

public int saveApp(OutStream out)

Save the app in binary format to the output stream:

  app
  {
    u4           magic 0x73617070 "sapp"
    u4           version 0x0002 0.2
    Schema       schema
    Component[]  comps
    u2           0xffff end of comps marker
    Link[]       links
    u2           0xffff end of links marker
    u1           '.' end of app marker
  }

Return 0 on success, non-zero on failure.

saveSchema

public void saveSchema(OutStream out)

Schema is the list of kit names and checksums:

  schema
  {
    u1  count
    kits[count]
    {
      str  name
      u4   checksum
    }
  }
startApp

public int startApp(Str[] args, int argsLen)

Start all the components. Return 0 on success, error code on failure.

stopApp

public void stopApp()

Stop all the components.