h3. Successful Startup sequence
- test applet is added to the page
- state: 'test applet appended'
- polls testApplet.areYouLoaded() to see wait for it to be ready
- real applet is added to the page _appendHTML( self.getHTML() )
- state: 'appended'
- polls appletInstance.getSensorRequest(this.measurementType)
- test applet is removed from the page
- state = 'applet ready'
- call isSensorConnected
- call applet.isInterfaceConnected(deviceType)
- util = SensorUtil.new(deviceType)
- call util.isCollectable
- call setupDevice(sensors: null)
- call createDevice
- call configureDevice(sensors: null, true)
- request = experimentRequest
- call configureExperimentRequest(request, null)
- call sensors = getSensorsFromCurrentConfig
- call device.getCurrentConfig
- copy sensorConfigs into sensorRequests
- if sensors == null return false
- call sensors = getSensorsFromCurrentConfig
- actualConfig = device.configure(request)
- if actualConfig == null then deviceIsCollectable = false
- configuredSensors = sensors
- deviceIsCollectable = true
- if device.isAttached
- return getDeviceConfig != null
- call setupDevice(sensors: null)
- call applet.getAttachedSensors if interfaceConnected returned true
- call applet.isInterfaceConnected(deviceType)
- if isSensorConnected returns false, notify an error to user
- call initializeSensor
- req = applet.getSensorRequest(this.measurementType) given a string type the applet returns a SensorRequestImpl instance that configured based on the type
- applet.initSensorInterface(this.listenerPath, this.deviceType, [req]);
- applet saves sensorReqs, and configures the device with them
- applet saves actualConfig and the set of sensors passed during the configuration
- applet checks if actualConfig is valid by comparing the sensors saved to the actualSensors (this should use actualConfig.isValid() instead)
- if actualConfig is valid applet calls back to javascript sensorsReady
- if actualConfig is not valid applet calls back to sensorsReady followed by sensorsUnplugged
- sensorsReady:
- startAppletCallback() <- makes sure there isn't a callback currently in process
- then sensorIsReady
- state: 'stopped'
- in setTimeout:
- _appendCallback(null) <- this callback is also used for sending errors
- _appendCallback = null
- endAppletCallback() <- makes sure there is a callback that this is finishing
- sensorsUnplugged
- currently does nothing
Questions Why is the test applet not removed as soon as it is succesfully polled?
Notes applet.isInterfaceConnected will return true if there are sensors set on the applet and it was previously collectable. This is because it calls SensorUtil#isCollectable.