Menu
  • Use Cases
  • Stacks
  • Stackbuilder
  • MyStacks
  • Support
  • About Us
  • Contact
  • Use Cases
  • Stacks
  • Stackbuilder
  • MyStacks
  • Support
  • About Us
  • Contact
  • View Cart

Data storage in Interstacks stacks

The Interstacks Base hardware block contains an 8GB repository for data storage in non-volatile Flash memory. Interstacks repositories have a built-in database to make saving and reading data easy to use. You use the built-in software blocks in the Data Storage category (of the Library palette in the right rail of Stackbuilder) to read and write data to/from the flash memory repository. Drag and drop the data storage block(s) you want to use from the blocks palette into your blueprint. There are blocks that provide basic functionality and ones that provide advanced database access.

We will now describe these blocks, from basic to advanced.

Data – One Value
A value to write is sent to Terminal 1. When you want to read that value, send any message to terminal 2. The value is sent out of the output terminal.

Data – One Value List
A value to write is sent to Terminal 1. It is appended to a list of all previous values sent to it. The values must be of the same type. When you want to read that value, send any message to terminal 2. The value is sent out of the output terminal as a Python list e.g. [1, 2, 3, 4]

Data – [Name, Value]
Input terminal 1 accepts a message that is a list of a Name and its value e.g. [‘Temperature’, 72]. The value will be written to the repository and will stay associated with the Name. When you want to read the value, send a list with just the Name e.g. [‘Temperature’]. The value will be sent out of the output terminal. You can send as many different [‘name’, value] pairs as you want. The values can be any valid Python value. This is sometimes referred to as a No-SQL, attribute-value store.

Its important to recognize that the Names used to store and retrieve data via this block will only work with this specific block, unless you use more advanced data storage blocks.

Data – [Name, Value] List
This block functions just like the “Data – [Name, Value] block, but values sent with the same name are appended to a list. All reads will be sent out as a Python list.

Its important to recognize that the Names used to store and retrieve data via this block will only work with this specific block, unless you use more advanced data storage blocks.

Advanced Data Storage
These next two data storage blocks are for advanced use and require understanding the underlying structure of the built-in database. Values are stored in the Interstacks built-in database using u-forms. A u-form is a UUID (large, unique number), followed by a list of name-value pairs. To read a value, you need its UUID and Name.

Data – [UUID, Name, Value, List]
Input terminal 1 accepts a list that is [UUID, Name,, <optionally 1 if want append to list> ]. If you send [ UUID, Name] the value is read and sent out the output terminal. If you send [ UUID, Name, Value] the value is written using the UUID and Name. If you send [ UUID, Name, Value, 1] the value is written and appended to the list of all previous values sent to that UUID-Name. When using the append to list option, the values must be of the same type and all the writes must have the list option set to 1.

Example to write a value: [UUID(‘~00443322667700’), ‘myfirstval’, 345] Example to read a value: [UUID(‘~00443322667700’), ‘myfirstval’] To generate a unique UUID, use: myUUID = UUID().

Data – UForms
The Data-UForms block supports movement through the entire built-in Interstacks data repository in the hardware stack. The repository stores data in non-volatile memory in the stack using the model of a UUID with a list of <Attribute Name – Value> pairs.
A UUID is a large, unique number. Each UUID can have an arbitrary number of <Attribute name – Value> pairs. This UUID, Name-Value list is called a Form. You can retrieve any value by using its UUID and Attribute name (use the “Data – [UUID, Name, Value, List]” software block). The value can be any valid Python type, from integers and character strings to lists and dictionaries. This type of model is sometimes referred to as a No-SQL database. There are other advanced database concepts that this model supports that we will leave to other documents.

Terminal 1 accepts a UUID.
If it receives a valid UUID, it outputs the entire list of Name-Value pairs for that UUID.
Output example: [ [‘value1’, 7], [‘value2’, 8] ] so firstName = value read[0][0] firstValue = valueread[0][1]

Terminal 3 – Get next u-form
If any message is sent to the second input terminal, the block moves to the next u-form stored in the repository and sends out the output terminal a list with the UUID and all of its Name-Value pairs.
Output example. [ UUID(‘~110044559988334422’), [‘value1’, 7], [‘value2’, 8] ] theUUID = valueread[0] firstName = valueread[1][0] firstValue = valueread[1][1]

If send it None, it starts at the first UUID in repository. It outputs None when it reaches the last u-form.

To start moving through a repository, send None to the second input terminal, then any message. The None will set up the next read to be from the first u-form in the repository. After the last u-form is read, the next GetNextUForm request will return None.

Refer to documentation on many other topics at interstacks.com/knowledge-base.

An academic paper on distributed databases and U-forms is here: “Toward the Universal Database: U-forms and the VIA Repository”

Please email info@interstacks.com with any questions.

Popular Articles

  • MyStacks Cloud Dashboard
  • Internet communication with HTTP block
  • Download and install Stackbuilder

Contact Us

Contact us with any questions or help with deploying your IoT projects.

CONTACT US

Connect

  • Facebook
  • Twitter
  • LinkedIn
  • Email

Sign up for the latest Interstacks news.

Join Our Newsletter
  Thank you for Signing Up
  Please correct the marked field(s) below.
1,false,1,First Name,2
Email:
1,true,6,Subscriber Email,2
Name:
1,false,1,Last Name,2

Copyright © 2023 Interstacks. All rights reserved. Privacy Policy | Terms and Conditions

Site by Imagebox