Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/morintd/automaton-core
A wrapper to help with controlling your automaton from an external controller.
https://github.com/morintd/automaton-core
Last synced: about 2 months ago
JSON representation
A wrapper to help with controlling your automaton from an external controller.
- Host: GitHub
- URL: https://github.com/morintd/automaton-core
- Owner: morintd
- License: mit
- Created: 2023-04-19T04:42:36.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-04-19T04:56:17.000Z (over 1 year ago)
- Last Synced: 2024-11-07T01:09:57.532Z (about 2 months ago)
- Language: TypeScript
- Size: 187 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# automaton-core
⚠️ This is a Work In Progress (WIP)
`automaton-core` is a TypeScript Wrapper for IOT/automaton/robot projects. It aims to provide an easy way to communicate with an external controller, so you can focus on what's important: behavior.
## Example
```typescript
// index.ts
import { BareConfig, AutomatonCore, SerialPortConnector, WebSocketConnector } from 'automaton-core';import { Automaton } from './automaton';
const config: BareConfig = {
id: 'main-automaton',
connectors: [
// {
// type: 'serial',
// options: {
// path: '/dev/ttyAMA0',
// },
// },
{
type: 'websocket',
options: {
address: 'ws://localhost:3000',
},
},
],
};function main() {
const automaton = new AutomatonCore({
config,
connectors: {
[SerialPortConnector.type]: SerialPortConnector.creator,
[WebSocketConnector.type]: WebSocketConnector.creator,
},
behavior: (write, config, logger) => {
return new Automaton(write, config, logger);
},
});automaton.start();
}main();
``````typescript
// automaton.ts
import { AutomatonBehavior, ActionType, BareConfig, ILogger, WriteAction } from 'automaton-core';export class Automaton implements AutomatonBehavior {
constructor(private write: WriteAction, private config: BareConfig, private logger: ILogger) {}handle(action: ActionType) {
this.logger.log('received action', { action });
this.write({
type: 'hello',
});
}start() {
this.logger.log('Started automaton!', this.config);
}stop() {
this.logger.log('Stopped automaton!');
return Promise.resolve();
}
}
```## Todo
- Complete documentation + a dd examples
- Create controller lib (& move them to an org?)