Code Blocks

Michael edited this page Oct 3, 2017 · 11 revisions

This page serves to explain the various blocks able for use in the Blocks page of App Inventor 2 for the iSENSEPublisher extension.

If you would like to learn about the various designer properties that need to be configured, please click the link below. Designer Properties

Control Blocks

UploadDataSetSucceeded

  • Event triggers when there is a successful data set upload or append. (See UploadDataSet and AppendDataSet below)
  • Has one variable to be accessed, DataSetID. When you use UploadDataSet and it succeeds, you will get back the Data Set ID associated with that particular upload. This DataSetID can then be used with the AppendDataSet block to add additional rows to a data set.

UploadDataSetFailed

  • Event triggers when there is a failed attempt of data set upload or append. (See UploadDataSet and AppendDataSet below)
  • Note that this event is NOT flagged when the app is attempting to upload without a signal. This only occurs when the uploading has been attempted with a signal, and there is an error in code blocks or in the way the iSENSE project is configured.

Procedure Blocks

UploadDataSet

  • This block creates a new data set on a given iSENSE project. It takes three different inputs.
  • DataSetName: desired name for the data set.
  • Fields: takes a list of text inputs corresponding to the iSENSE project's fields. Needs to match up exactly, case-sensitive.
  • Data: takes a list of inputs. Needs to match up with the order of the Fields list directly above it.
  • Below is an example of Fields in a particular iSENSE project.

  • How can we set up our UploadDataSet block to work with these particular fields?

  • Viewed below is an example. Notice that "Name" is the first element in the List for "Field" and for "Data" is a particular name, in this case, "Michael". The arrows show how the points in the list for "Field" and list for "Data" pair off.

  • Note that the order of field names on the iSENSE project page and our App Inventor block are not the same. The order of the Fields on the App Inventor project does not matter, as long as the Field names have the same spelling and capitalization as the ones on the iSENSE webpage.

AppendDataSet

  • This block will append a new row of data to an existing data set. This block takes three different inputs.
  • DataSetID: The data set ID of the data set you wish to append to. After using the UploadDataSet blcok, this ID can be accessed by using the UploadDataSetSucceeded block.
  • Fields: takes a list of text inputs corresponding to the iSENSE project fields. Needs to match up exactly, is case-sensitive.
  • Data: takes a list of inputs. Needs to match up with the order of the Fields list directly above it.
  • Note, however, you can not append to any data sets that were not uploaded using your current Contributor Key. Below is an example of a completed AppendDataSet block, and one method of retrieving Data Set IDs.

[image]

GetAllDataFromProjectByField

  • This block will return a list of data inputs of a particular fields in the iSENSE project. Takes one input.

  • Field: The field name of the field you wish to retrieve data from.

  • To give an example, we uploaded three data sets with the number '5' as their value for the "Favorite Number" number field.

  • If we used the GetAllDataFromProjectByField, we would be returned with a list with the contents [5, 5, 5].

GetAllDataFromDataSetByField

  • This block will return a list of data inputs of a particular fields for one particular data set in the iSENSE project. Takes two inputs.

  • DataSetID: The data set ID of the data set you wish to retrieve data from.

  • Field: The field name of the field you wish to retrieve data from.

  • To give an example, we uploaded three data sets with the number '5' as their value for the "Favorite Number" number field.

  • If we used the GetAllDataFromProjectByDataSet for one particular data set, we would only get one '5' as opposed to all three uploaded for the entire project.

GetAllDataSetIDs

  • This block will return a list of all Data Set IDs from all Data Sets associated with a particular iSENSE project.

GetTime

  • This block is intended for use with UploadDataSet and AppendDataSet. This block returns the current time in the same format used for the Timestamp field type in iSENSE. If you want to upload any data on a project that uses Timestamp, you would use this block. If you try to send the time in a different format, it will not work.

GetVisURL

  • Returns a URL of the current Project. Will include all data sets. This will be in presentation mode, which will hide the top menu bar where you can select different visualization types
  • This block will automatically use the VisType property, which is explained more on the Properties page. See here Properties.

Home

Installation

Setting up iSENSE

Designer Properties

  • ContributorKey
  • ProjectID
  • VisType

Code Blocks

  • UploadDataSetSucceeded
  • UploadDataSetFailed
  • GetDataSetsByField
  • GetNumberPendingUploads
  • GetTime
  • GetVisURL
  • GetVisWithControlsURL
  • UploadDataSet
  • AppendDataSet

Manual Testing

Notes for Future Developers

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.