2.0.6-rc5 • Published 10 months ago

testhelyos-sdk v2.0.6-rc5

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

About The Project

The helyosjs-sdk helps the development of javascript applications using the helyOS framework. This library contains all necessary methods and entity types to build a front-end using helyOS as backend system.

npm.io

List of features

  • Log in as administrator or regular user.
  • List and edit automatons (agents).
  • Retrieve sensors data and work process status.
  • Create, schedule and handle work processes.
  • Manage and edit yards: set drivable areas, gates, obstacles, etc.

Built With

Getting Started

Installation

$ npm i helyosjs-sdk  --save

Usage

import { HelyosServices, H_Agents  } from 'helyosjs-sdk';

const helyosService = new HelyosServices('http://localhost', {socketPort:'5002', gqlPort:'5000'});

const username = 'admin@email.com';
const password = 'password';

 helyosService.login(username, password)
.then( response => helyosService.connect())
.then( connected => console.log(connected));;

function listAgents(conditions={}) {
    return helyosService.agents.list(conditions)
    .then((agents: H_Agent[]) => {
        console.log(agents);
    });
}

function editTool(patch: H_Agents) {
    return helyosService.agents.patch(patch)
    .then(agents => {
        console.log(agents);
    )}
}

Listening agent/agent sensors and work process status

helyosService.connect()
.then(() => {
            const socket = helyosService.socket;

            socket.on('new_agent_poses',(updates)=>{
                console.log(updates);  // Notifications from agent sensors.
            });

            socket.on('change_agent_status',(updates)=>{
                console.log(updates);  // Notifications from agents working status.
            });

            socket.on('change_work_processes',(updates)=>{
                console.log(updates);  // Notifications from work processes status.
            });
});

Command Reference

CommandDescription
helyosService.register(email,password,adminPassword): PromiseRegister new user.
helyosService.login(username, password): PromiseUser login.
helyosService.connect(): PromiseEstablish websocket connection after logged.
helyosService.logout(): PromiseUser logout.
helyosService.changePassword(user,password,newPassword): PromiseChange password.
------
EXAMPLE OF CRUD OPERATIONS
helyosService.workprocessWork Processes services
.list (condition: Partial<H_WorkProcess>): Promise<H_WorkProcess[]>list all work processes filtered by condition.
.create (data: H_WorkProcess): Promise<H_WorkProcess>create work process.
.get (workProcessId: number): Promise<H_WorkProcess>get work process by ID.
.patch (data:Partial<H_WorkProcess>): Promise<H_WorkProcess>edit work process.
------

Most important models

ModelDescription
H_AgentsTool represents a sensor or any movable device that can perform an action
id: numberunique db identifcation number
code: numberunique identifcation number
name: stringagent name
picture: stringbase64 jpg
yardId: numberto which yard this agent is associated.
status: string'busy', 'free'
picture: stringbase64 jpg
geometry: JSONDescription of the agent geometry
heartbeat: DateLast time agent contacted the yard base
------
H_YardPhysical space enclosing agents in a drivable area.
id: numberunique db identifcation number
name: stringyard name
picture: stringbase64 jpg
mapData: {origin: {lat?: number, lon?: number, zoomLevel?: number}}base64 jpg
------
H_MapObjectDefine objects in the yard map: areas or lines.
id: numberunique db identifcation number.
yardId: numberassociated yard.
deletedAt: Datewhen shape was marked deleted.
type: stringtype of object: "obstacle", "parking-area", "gate", etc.
data: Objectuser-defined arbitrary data format
dataFormat: stringname of the data format
------
H_WorkProcessGroup and serialize actions to be executed by the agents.
id: numberunique db identifcation number.
schedStartAt: datedate and time when the process is scheduled to start.
schedEndAt: datedate and time when the process is predicted to end.
startedAt: datedate and time of actual start.
endedAt: datedate and time of actual end.
status: stringstatus.
processType: stringstatus.
data: MoveToTargetDescriptor | MoveFreeDescriptionAny JSON data that describes the actions.
------

Contributing

Keep it simple. Keep it minimal. If you have any question, please write to our Discussion forum.

License

This project is licensed under the MIT License