Skip to content

The Smathouse's File System

Ron Gatenio edited this page Jul 1, 2017 · 7 revisions
The Smathouse system is an event-driven system. The File System is the event-system's core. It acts both as a data storage, and also as an event dispatcher. Messages are sent to the File System, get stored there, and get dispatched through the system. Event handlers that have subscribed to the File System, will be notified when a path in the File System has been updated.

The File System's Structure and Paths

The File System has a hierarchical tree structure. Each node in the tree has a name, and contains data and a list of event handlers (Consumer functions).

Accessing nodes in the File System is done via a string path, like: stove.is_on, billing.water, and etc.

Event handlers subscribe on any path. When a new data is sent on that path, an event will be fired to all subscribers. For example, if an event handler subscribes on the path: system.internals, they will be notified when ever new data is sent on that branch (paths of the form: system.internals.*).

Special Uses within the Smarthouse

Sensors

The File System is heavily integrated to the sensors communication component of the system.
The sensors' hardware sends <path, data> messages to the system. Then, the sensors' local server sends the given data on the File System. All event handlers will be notified, including the applications that are listening on these paths with the SensorApi or with the FileSystemService.

Saving the house

When ever a system component decides to save the system image to the cloud or local database, it sends a message on the path: system.internals.saveme. The SystemCore always listens on this path, and when the event occurs, it saves the system's image.

Storing persistent data

Parts of the File System are saved to the cloud. When the house loads, it can add entries to its File System form the loaded system image. This feature is especially used by the applications. Applications can read and write private data to the File System. Each application gets a separate entry, and they have no way of accessing other applications' saved data.

Clone this wiki locally