Project realised in IMAC Engineering School.
-
Download zip file or clone the git repository
-
Move it to your third-party directory
-
In your third-party's CMakeLists.txt, add Bec3-lib subdirectory's
add_subdirectory(Bec3-lib)
-
In your project's CMakeLists.txt, include Bec3-lib directory's and set BeC3-lib
include_directories(third-party/Bec3-lib/include/) set(Bec3-lib)
- Download Web-Lite
- Install JAVA ORACLE JDK 8
- Install SBT
- Follow the instructions in the README file
Linux and Mac OSX :
./weblite-api
Windows :
./weblite-api.bat
Linux :
$ sudo apt-get install cmake
Mac OSX :
$ brew install cmake
Download CURL
Bec3 mySession;
There are two ways to init the session, you can pass a json initialization file as a constructor parameter, or pass your username and password as constructor parameters too.
- The file way
Bec3 mySession = new Bec3("assets/conf/Bec3.json");
Notice that you can delay the file initialization with the initFromFile()
method
Bec3 mySession;
mySession.initFromFile("assets/conf/Bec3.json");
Example JSON configuration file :
{
"user": {
"login" : "corentin.limoge",
"password" : "coucou"
}
}
- The login way
Bec3 mySession = new Bec3("username", "password");
For create a virtual object, you need to add an object to your session. You had to use the addObject()
method
mySession.addObject("id", "type");
The id of the object is simply its name, you can choose whatever you want.
There are four types of object :
- gauge : The gauge can be "filled" by others objects of the BeC3 platform.
- slider : The slide can take a value between 0 and 255.
- light : Like a real light, it can take two states, true or false.
- msg-receiver : This object can receive a text message.
mySession.addObject("myLight", "light");
If you want to get the state of an object, the Bec class has the method getObjectState()
which takes the ID of the object and which returns a state object.
mySession.getObjectState("id");
You can perform four actions on a state :
- retrieve the ID (in a string) :
mySession.getObjectState("id").getId();
- retrieve the string value :
mySession.getObjectState("id").getString();
- retrieve the int value :
mySession.getObjectState("id").getInt();
- retrieve the boolean value :
mySession.getObjectState("id").getBool();
Each object have a state, depending of its type.
You had to update the different states of the objects before you want use it.
The method updateObjects()
is made for that.
mySession.updateObjects();