|
| 1 | +<div id="top"></div> |
| 2 | + |
| 3 | + |
| 4 | +<!-- PROJECT LOGO --> |
| 5 | +<br /> |
| 6 | +<div align="center"> |
| 7 | + <a href="https://helyosframework.org/"> |
| 8 | + <img src="helyos_logo.png" alt="Logo" height="80"> |
| 9 | + </a> |
| 10 | + |
| 11 | + <h3 align="center">helyOS Javascript SDK</h3> |
| 12 | + |
| 13 | + <p align="center"> |
| 14 | + A Javascript wrap for helyOS GrapQL interface. |
| 15 | + <br /> |
| 16 | + <a href="https://helyOSFramework.github.io/helyos-javascript-sdk/"><strong>Explore the docs »</strong></a> |
| 17 | + <br /> |
| 18 | + <br /> |
| 19 | + <a href="https://github.com/">View Demo</a> |
| 20 | + · |
| 21 | + <a href="https://github.com/helyOSFramework/helyos-javascript-sdk/issues">Report Bug</a> |
| 22 | + · |
| 23 | + <a href="https://github.com/helyOSFramework/helyos-javascript-sdk/issues">Request Feature</a> |
| 24 | + </p> |
| 25 | +</div> |
| 26 | + |
| 27 | +## About The Project |
| 28 | + |
| 29 | +The helyosjs-sdk helps the development of javascript applications using the helyOS framework. |
| 30 | +This library contains all necessary methods and entity types to build a front-end using helyOS as backend system. |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | +### List of features |
| 36 | + |
| 37 | +* Log in as administrator or regular user. |
| 38 | +* List and edit automatons (agents). |
| 39 | +* Retrieve sensors data and work process status. |
| 40 | +* Create, schedule and handle work processes. |
| 41 | +* Manage and edit yards: set drivable areas, gates, obstacles, etc. |
| 42 | + |
| 43 | + |
| 44 | +### Built With |
| 45 | + |
| 46 | +* [Typescript](https://www.typescriptlang.org/) |
| 47 | +* [Apollo](https://www.apollographql.com/) |
| 48 | +* [Socket.io](https://socket.io/) |
| 49 | + |
| 50 | +## Getting Started |
| 51 | + |
| 52 | +### Installation |
| 53 | + |
| 54 | +```shell |
| 55 | +$ npm i helyosjs-sdk --save |
| 56 | +``` |
| 57 | + |
| 58 | +### Usage |
| 59 | + |
| 60 | +```js |
| 61 | +import { HelyosServices, H_Agents } from 'helyosjs-sdk'; |
| 62 | + |
| 63 | +const helyosService = new HelyosServices('http://localhost', {socketPort:'5002', gqlPort:'5000'}); |
| 64 | + |
| 65 | +const username = 'admin@email.com'; |
| 66 | +const password = 'password'; |
| 67 | + |
| 68 | + helyosService.login(username, password) |
| 69 | +.then( response => helyosService.connect()) |
| 70 | +.then( connected => console.log(connected));; |
| 71 | + |
| 72 | +function listAgents { |
| 73 | + return helyosService.agents.list(0) |
| 74 | + .then((agents: H_Agent[]) => { |
| 75 | + console.log(agents); |
| 76 | + }); |
| 77 | +} |
| 78 | + |
| 79 | +function editTool(patch: H_Agents) { |
| 80 | + return helyosService.agents.patch(patch) |
| 81 | + .then(agents => { |
| 82 | + console.log(agents); |
| 83 | + )} |
| 84 | +} |
| 85 | +``` |
| 86 | +
|
| 87 | +### Listening agent/agent sensors and work process status |
| 88 | +
|
| 89 | +```js |
| 90 | + |
| 91 | +helyosService.connect() |
| 92 | +.then(() => { |
| 93 | + const socket = helyosService.socket; |
| 94 | + |
| 95 | + socket.on('new_agent_poses',(updates)=>{ |
| 96 | + console.log(updates); // Notifications from agent sensors. |
| 97 | + }); |
| 98 | + |
| 99 | + socket.on('change_agent_status',(updates)=>{ |
| 100 | + console.log(updates); // Notifications from agents working status. |
| 101 | + }); |
| 102 | + |
| 103 | + socket.on('change_work_processes',(updates)=>{ |
| 104 | + console.log(updates); // Notifications from work processes status. |
| 105 | + }); |
| 106 | +}); |
| 107 | + |
| 108 | + |
| 109 | +``` |
| 110 | +
|
| 111 | +### Command Reference |
| 112 | +
|
| 113 | +| Command | Description | |
| 114 | +| --- | --- | |
| 115 | +| `helyosService.register(email,password,adminPassword): Promise` | Register new user. | |
| 116 | +| `helyosService.login(username, password): Promise` | User login. | |
| 117 | +| `helyosService.connect(): Promise` | Establish websocket connection after logged. | |
| 118 | +| `helyosService.logout(): Promise` | User logout. | |
| 119 | +| `helyosService.changePassword(user,password,newPassword): Promise` | Change password. | |
| 120 | +| --- | --- | |
| 121 | +| EXAMPLE OF CRUD OPERATIONS | | |
| 122 | +| `helyosService.workprocess` | Work Processes services | |
| 123 | +| .list (condition: Partial<H_WorkProcess>): Promise<H_WorkProcess[]>| list all work processes filtered by condition. | |
| 124 | +| .create (data: H_WorkProcess): Promise<H_WorkProcess> | create work process. | |
| 125 | +| .get (workProcessId: number): Promise<H_WorkProcess> | get work process by ID. | |
| 126 | +| .patch (data:Partial<H_WorkProcess>): Promise<H_WorkProcess> | edit work process. | |
| 127 | +| --- | --- | |
| 128 | +
|
| 129 | +
|
| 130 | +
|
| 131 | +### Most important models |
| 132 | +
|
| 133 | +| Model | Description | |
| 134 | +| --- | --- | |
| 135 | +| `H_Agents` | Tool represents a sensor or any movable device that can perform an action | |
| 136 | +| id: number | unique db identifcation number | |
| 137 | +| code: number | unique identifcation number | |
| 138 | +| name: string | agent name | |
| 139 | +| picture: string | base64 jpg | |
| 140 | +| yardId: number | to which yard this agent is associated.| |
| 141 | +| status: string | 'busy', 'free' | |
| 142 | +| picture: string | base64 jpg | |
| 143 | +| geometry: JSON | Description of the agent geometry | |
| 144 | +| heartbeat: Date | Last time agent contacted the yard base | |
| 145 | +| --- | --- | |
| 146 | +| `H_Yard` | Physical space enclosing agents in a drivable area. | |
| 147 | +| id: number | unique db identifcation number | |
| 148 | +| name: string | yard name | |
| 149 | +| picture: string | base64 jpg | |
| 150 | +| mapData: {origin: {lat?: number, lon?: number, zoomLevel?: number}} | base64 jpg | |
| 151 | +| --- | --- | |
| 152 | +| `H_MapObject` | Define objects in the yard map: areas or lines. | |
| 153 | +| id: number | unique db identifcation number. | |
| 154 | +| yardId: number | associated yard.| |
| 155 | +| deletedAt: Date | when shape was marked deleted. | |
| 156 | +| type: string | type of object: "obstacle", "parking-area", "gate", etc. | |
| 157 | +| data: Object | user-defined arbitrary data format | |
| 158 | +| dataFormat: string | name of the data format | |
| 159 | +| --- | --- | |
| 160 | +| `H_WorkProcess` | Group and serialize actions to be executed by the agents. | |
| 161 | +| id: number | unique db identifcation number. | |
| 162 | +| schedStartAt: date | date and time when the process is scheduled to start. | |
| 163 | +| schedEndAt: date | date and time when the process is predicted to end. | |
| 164 | +| startedAt: date | date and time of actual start. | |
| 165 | +| endedAt: date | date and time of actual end. | |
| 166 | +| status: string |status. | |
| 167 | +| processType: string |status. | |
| 168 | +| data: MoveToTargetDescriptor \| MoveFreeDescription | Any JSON data that describes the actions. | |
| 169 | +| --- | --- | |
| 170 | +
|
| 171 | +
|
| 172 | +
|
| 173 | +
|
| 174 | +### Contributing |
| 175 | +
|
| 176 | +Keep it simple. Keep it minimal. |
| 177 | +If you have any question, please write to our [Discussion](https://github.com/helyOSFramework/helyos_core/discussions/) forum. |
| 178 | +
|
| 179 | +
|
| 180 | +### License |
| 181 | +
|
| 182 | +This project is licensed under the MIT License |
0 commit comments