Tool Prototype for Creating Smart House Simulations


The Prototype was create using Flash MX 2004 technology. It contains a set of basic graphical object representing a floor plan of a house, furniture, sensors and equipment so they can be easily duplicated and placed in a desired position. Several animations are connected with each sensor and each piece of equipment to visualise that a sensor is detecting something or that a piece of equipment is working or changing its state. A simple mechanism of moving an inhabitant is also implemented to the prototype. Finally a set of functions is created so a user can create a simple script that would perform a desired animation of moving the inhabitant, triggering the sensors and switching the equipment on or off. The link to the source file is located below:

Flash source file

User Guide

Creating the house

The house is created by dragging the objects from the library onto the stage, onto a proper layer. For using own floor plans, first the image has to be imported to the library and then dragged on the stage. Afterwards the position, angles and sizes can be easily adjusted using the flash editing options. The next step is to give instance names to all the inhabitants, equipment and sensors. In majority, the naming convention is flexible, as long as the same instance names are used afterwards in the script. There are some exceptions in sensors and in the inhabitant instance name. The inhabitant should be call "mcInhabitant" (the mc stands for Movie Clip and is used according to naming convention proposed by Flash). This enables the functionality of moving an inhabitant by simply clicking on any place on a stage. The second exception are sensors. A sensor is placed using two objects. One is the sensor base and the other is a senor area. They should be named mcSArea# and mcSBase# respectively, where # is a number from 1 to 99 that has to be identical in both names. This way when a properly named inhabitant enters the sensor area, the sensor base will animate. There is one additional requirement for changing a shape of the sensor area. As the change is made inside the symbol, thus changing the shape of one sensor area is changing the shape in all instances of that object. To avoid this, each time the sensor area is needed it should be duplicated in the library first. Then every sensor area on a stage would be an instance of different object and there would be no problem in changing the shape of the area without affecting other sensors.

In this place a small simulation of a Smart House is already created. A user who is interested in implementing some Smart House technologies in his or her house can plan the placement of the sensors in a house. He or she can place the sensors in the desired way, adjust the sensor areas and check which sensors are triggered when an inhabitant is moving from one place to another.

Scripting functionality

The scripting functionality allows for easy creation of Smart House animations. The animations can be conveniently shown to the people on a presentation as the functionality of altering the animation is present. Additionally the functionality of message box, where all necessary description can be displayed during the animation allows for placing the animation on a website. Hence there is no need to explain the animations as all comment appear on the screen.

Before writing the script the house with all necessary objects has to be created on a stage and all the appropriate instance names have to be assigned. The scenario has to be planned, so all the movement points are placed in the desired positions and then the script has to be written. The script has to be placed in the "Action" layer in the following place in the small block of code presented here:


_root.onEnterFrame = function() {
_root.currentFunction = 0;

// the beginning of the script - write the commands below
}



The function calls have to be written between the commented lines announcing the beginning and the end of the script. The rest of the lines are the instructions that are necessary for the script to work. It is worth to remember that the message displayed in the message box is being appended to it at the top. Thus there is a need to place \n sign at the end of each message. Additionally it is worth to put a number in each message so the messages would be clearer. The instructions of how to extend the prototype with new elements or new functions are placed in the next subsection.

Possible extensions and extension guideliness

One of the features of the prototype is the possibilities of easy extensions. Various items can be added with just basic knowledge of Flash MX technology. Among such items are the floor plans and furniture. Both of those types of elements are just static graphics that are practically only a decoration. It is possible to create a simple shape by using the flash environment and then to convert the graphics into a symbol, so it would be placed in the library and could be reused later. It is also possible to create the image in any other program or download an image from the Internet as flash is capable of importing various formats of images.

Creating new equipment with some animations is a little bit more difficult task. The basic shape of the object has to be created in flash, then the object has to be extended to several frames and then the frames has to be edited to create the animations. There are few requirements for such an animation so it would be compatible with the scripting functionality. The first frame, which is a switched off state of the equipment has to contain the call to stop() function that would prevent the animation from playing all the time. The actual animation has to start from the second frame. In the last frame of the animation some instructions can be placed as well. If it is intended that the animation stops in this point, the call to stop() function has to placed as well. In case the animation is intended to loop, the instruction that makes the animation to go back to second frame (gotoAndPlay(2)) is needed. If the animation is intended to go bask to the switched off state, no code is needed.

The next step of the extensions of the prototype is the possibility of adding a new function to the script language. It is very easy to do it with the functions that perform its actions instantly. When there is no movement that is altering the execution of the next functions in the script. In such a way there is an clear template of such function which looks in the following way:

function nameOfTheFunction([parameter1, parameter2, …]) {
}

Just the name of the function needs to be created, any necessary parameters have to be named and of course the actual actions have to written. The other lines deal with all the variables that enforce the proper functioning of the script.

It is much more difficult with the functions that are intended to perform some actions over a period of time, and no other script functions can be executed in that time. Still there is a template for such type of a function as well:

function nameOfTheFirstFunction([parameter1, parameter2, …]) {
}


function nameOfTheSecondFunction([parameter1, parameter2, …]) {
}


Again the names of the functions and parameters have to be created and changed in the template. The first function that is the function called from the script is intended to have just initialisation purposes. There if it is necessary the exact number of milliseconds for the setInterval () function has to be calculated. Also other initialization has to be made in order for the second function to perform the task. The second function is a function that is run a defined number of times, until the counter reaches zero. There all the necessary operations that perform a desired task should be placed.