The documentation is not complete.

Modules 

FullJS environment uses the build-in ES6 module system. There is exactly one module per file and one file per module. The modules can be loaded statically by the import statement and dynamically by the import() function call. 

Import example on client side:

[remote_content url="http://jdesktop.com/node1/jmodule/client.js?notranspile=true"]
Open

Events 

FullJS’s Core API is built around an idiomatic asynchronous event-driven architecture in which EventTarget objects can receive events and may have listeners for them.

When the EventTarget object receives an event, all of the functions attached to that specific event are called synchronously. Any values returned by the called listeners are ignored and will be discarded.

eventTarget.addEventListener(type, listener)

The EventTarget method addEventListener() sets up a function that will be called whenever the specified event is delivered to the target.

eventTarget.removeEventListener(type, listener)

The EventTarget.removeEventListener() method removes from the EventTarget an event listener previously registered with EventTarget.addEventListener()

eventTarget.dispatchEvent(event)

Dispatches an Event at the specified EventTarget, (synchronously) invoking the affected EventListeners in the appropriate order.

Usage:

[remote_content url="http://jdesktop.com/node1/jevents/server.jss?notranspile=true"]

console 

The console object provides access to the systems’s debugging console.

console.log(message)

Outputs a debug message to the console

console.info(message)

Outputs an informational message to the console

console.warn(message)

Outputs a warning message to the console

console.error(message)

Outputs an error message to the console

 

Filesystem 

The fs module provides an API for interacting with the file system in a manner closely modeled around standard POSIX functions.

Currently only synchronous operations are implemented.

fs.mkdirSync(path)

Synchronously creates a directory. Returns undefined.

fs.rmdirSync(path)

Synchronously removes a directory. Returns undefined.

fs.readFileSync(path[, options])

Synchronously reads the content of a file. Returns ArrayBuffer.

fs.writeFileSync(path, data[, options])

Synchronously writes data to the file, replacing the file if it already exists.

fs.appendFileSync(path, data[, options])

Synchronously append data to a file, creating the file if it does not yet exist.

fs.unlinkSync(path)

Synchronously removes a file or symbolic link.

fs.copyFileSync(src, dest[, flags])

Synchronously copies src to dest. By default, dest is overwritten if it already exists. Returns undefined.

fs.statSync(path[, options])

 Return information about a file.

fs.existsSync(path)

Returns true if the path exists, false otherwise.

Worker 

Worker(path)

Creates a new worker instance that runs in the background independently of other scripts.

worker.postMessage(message)

Send a message to the worker instance.

message:

The object to deliver to the worker; this will be in the data field in the event delivered to the worker’s global onmessage handler. This may be any value or JavaScript object handled by the structured clone algorithm.

worker.terminate()

Terminate a web worker, and free its resources.

worker.onmessage = function(event) {}

The onmessage handler is called on a Worker object when the worker’s parent receives a message from its worker (i.e. when the worker sends a message using global.postMessage()).

The message itself is available in the message event’s data attribute

Example:

server.jss:

[remote_content url="http://jdesktop.com/node1/jworker/server.jss?notranspile=true"]

worker.jss:

[remote_content url="http://jdesktop.com/node1/jworker/inc/worker.jss?notranspile=true"]
Open

Serial 

Serial()

Creates a new serial instance

serial.open(device, options)

Opens the specified device.

device:

Device driver path such as “/dev/ttyAMA0” or “/dev/ttyUSB0” etc.

options:

  • baudrate (number) – Baud rate such as 9600 or 115200 etc.
  • databits (number) – Number of data bits. Possible values: 5, 6, 7, 8
  • parity (string) – Enable parity checking. Possible values: “odd”, “even”, “none”
  • stopbits (number) – Number of stop bits. Possible values: 0, 1, 2
  • xonxoff (boolean) – Enable software flow control.
  • rtscts (boolean) – Enable hardware (RTS/CTS) flow control.

serial.close()

Close device immediately.

serial.send(data)

Enqueues data to be transmitted.

data:

Data to be transmitted..

serial.flush()

Flushes (discards) both data received but not handled (by onmessage handler), and data sent (by send method) but not transmitted.

serial.onmessage = function(event) {}

onmessage handler is called whenever any data are available.

event.data:

Data received.

serial.onerror = function(event) {}

onerror handler is called whenever there is any error.

event:

The error object representing the cause of error.

Possible error types:

  • RangeError when parameter are out of range, e.g. baud rate, data bits.
  • Error when the error is generated by the underlying operating system

serial.onsuccess = function(event) {}

onsuccess handler is called whenever the requested operation finishes successfully. (such as: open, flush, close)

Server 

Implements the web application server functionalaties. (e.g.: handles http request, handles websocket connections, handles remote method invocations, user management, etc.)

server.onconnect(client) 

onconnecte method is called when there is a new client request to connect.

A new client request can either be:

  • accepted by returning true
  • rejected by returning false (In this case the client will get HTTP-404 Forbidden)

server.onopen(client)

onopen method is called when the new client is connected. After that, the client can invoke remote methods defined in the server instance or the server can notify the client. (client.notify)

Do not forget to call base method (super.onopen(client))

server.RM_[method name](request, …)

Method names starting with “RM_” are remote methods, thus can be called by the clients.

A remote method invocation can be either be resolved or rejected asynchronously by:

  • resolving the returned promise
  • rejecting the returned promise

Or a request can either be resolved or rejected synchronously by:

  • returning any value except a promise
  • throwing an exception
If a remote method returns a promise that never resolves or rejects then the invocation will not be responded.

Example:

server.jss:

[remote_content url="http://jdesktop.com/node1/jserver/server.jss?notranspile=true"]
Open

Pin 

A class to control the GPIO pins.

Pin(device, pin)

Creates a new pin instance.

device:

Device driver or sysfs interface path. (For example: On Raspberry PI: “/sys/class/gpio”, on stm32: “GPIOD”)

pin:

Pin number

pin.value

Synchronously sets/gets the value of the pin instance. 

Possible values: 

  • 0 for low
  • 1 for high

pin.direction

Synchronously sets/gets the direction of the pin instance. 

Possible values: 

  • 0 for output
  • 1 for input

pin.onchange

Synchronously sets/gets the onchange method of the pin instance.  This event handler is called on both rising and falling edges.

Example:

 

PWM   

A class to control the GPIO pins.

PWM(device, pin)

Creates a new pin instance.

device:

Device driver or sysfs interface path. (For example: On Raspberry PI: “/sys/class/pwm/pwmchip0”, on stm32: “PWM”)

pin:

Pin number

pwm.period

PWM period in nanoseconds.

pwm.duty_cycle

PWM pulse width in nanoseconds.

 

I2C 

Asynchronous module for the i2c device. All operations return a promise.

Byte: 8-bit unsigned integer

Word: 16-bit signed integer, interpreted as little-endian (as specified by the SMBus spec)

new I2C()

Creates a new i2c instance.

i2c.open(device, chip_address)

Asynchronous open. Returns a Promise that, when resolved, the i2c bus is ready for transmission.

device:

Device driver path. (For example: On Raspberry PI: “/dev/i2c-1”, on stm32: “I2C1”)

chip_address:

7-bit address of the chip.

i2c.read(length)

Asynchronous read. Returns a Promise that, when resolved, yields an ArrayBuffer containing the values read.

i2c.write(arrayBuffer)

Asynchronous write. Returns a Promise that, when resolved, the transmission was successfull.

i2c.close()

Asynchronous close. Returns a Promise that, when resolved, the close operation was successfull.

i2c.readByte()

Read a single byte from the device, without specifying a device register.

i2c.writeByte(byte)

Send a single byte to the device.

i2c.readByteData(reg)

Read a single byte from the specified register.

i2c.writeByteData(reg, byte)

Write a single byte to the specified register.

i2c.readWordData(reg)

Read a single word from the specified register.

i2c.writeWordData(reg, word)

Write a single word to the specified register.

gui 

GUI module is a curated set of control (widget) elements.

Each GUI control element are built around a common ancestor: WebComponent (which is a a simple base class for creating fast, lightweight web components)

Button(properties)

Enhances standard input element with additional properties and with appropriate hover and active styles.

Additonal properties:

  • icon – icon of the button
  • label – label of the button
GUI can be create with the visual designer but now for the sake of example it is created at runtime.

Example:

[remote_content url="http://jdesktop.com/node1/jbutton/client.js?notranspile=true"]
Open

Icon(properties)

Represents a icon, which is a small bitmap image that is used to represent an object. 

Naming convention follows the Icon Naming Specification.

Additonal properties:

  • size – can be: 16,32,64,128,256
  • context – Contexts for the icon theme, such as: actions, devices, mimetypes
  • iconname – name of the icon, such  as: view-refresh, view-fullscreen

 

Class  

Collection of methods for the late modification of already defined classes.

Class.hook(into, what)

Hooks a class into the prototype chain of an already defined class.

what

Class definition that will be injected.

into

The class definition into which the other class will be inserted.

Usage:

Useful (for example) when there is a collection of pre-defined services and we would like to enable these services in our main application server.

./inc/service.js

[remote_content url="http://jdesktop.com/node1/jclasshook/inc/service.js?notranspile=true"]

server.jss

[remote_content url="http://jdesktop.com/node1/jclasshook/server.jss?notranspile=true"]
Open

DS1621 

Module for the DS1621 Digital Thermometer and Thermostat.

new DS1621()

Creates a new ds1621 instance.

ds1621.open(device, address)

Iherited from I2C module

ds1621.close()

Iherited from I2C module

ds1621.getTempererature()

Asynchronous read. Returns a Promise that, when resolved, yields a Number which is the sensed temperature.

ds1621.setThermalAlarm(TH)

Sets the thermal alarm output to a specified temperature in Celsius.

TH

When the device exceeds TH Tout pin will be active.

Example:

GSS 

Module for the COZIR™, SprintIR™, MISIR™ and MinIR™ CO2 Sensors. This is an async module, each operation returns a promise.

For detailed documentation please visit: http://co2meters.com/Documentation/Manuals/Manual_GSS_Cozir_SprintIR_LP_GSS_Revised8.pdf

new GSS()

Creates a new gss instance.

gss.open(device)

Open the device at the given serial port.

gss.close()

Close the device.

gss.getDeviceInformation()

Return firmware version and sensor serial number.

gss.setOperatingMode(mode) 

Selects the operating mode. Operating modes can be:

  • GSS.MODE_COMMAND
  • GSS.MODE_STREAMING 
  • GSS.MODE_POLLING 

gss.setDigitalFilter(n)

Set the digital Filter

gss.getDigitalFilter() 

Return the digital filter setting.

gss.getFilteredGasConcentration() 

Return the most recent CO2 measurement.

gss.getTemperature()

Return the most recent temperature measurement.

gss.getRelativeHumidity()

Return most recent humidity measurement.

gss.zeroCalibrateIn0ppm()

Zero point calibration using nitrogen.

gss.zeroCalibrateIn400ppm() 

Zero point calibration using fresh air.

gss.zeroCalibrateIn(ppm)

Zero point setting using a known gas calibration.