nope/modules/tinkerforge/README.md

164 lines
4.8 KiB
Markdown
Raw Normal View History

2021-05-13 08:00:34 +00:00
# TinkerForge-Module
This Module integrates the TinkerForge-Bricks into the System.
Therefore the class `BaseGenericBrick` is utilized. This class implements the default functionalities of a Brick and allows an integration into the control system.
# ToDos
- [ ] Add callback for connect Method (Brick-Factory)
- [ ] Setup-Brick-Factory allowing multiple connections
- [ ] Update Documenation
- [ ] Document the possible Configurations
- [ ] Add Example
# Description
To include **Bricklets** into the control System a Brick Factory is used.
```typescript
/** Create a TinkerForge-Connector remotely connected */
const _connectorPOE = _container.get<TINKERFORGE.BrickFactory>(TINKERFORGE.TYPES.BrickFactory);
_connectorPOE.connect(undefined, '192.168.178.10');
/** Create a TinkerForge-Connector, connected with USB */
const _connectorUSB = _container.get<TINKERFORGE.BrickFactory>(TINKERFORGE.TYPES.BrickFactory);
/** No Parameters are set ==> USB */
_connectorUSB.connect();
```
After the connection has been established a provided *configuration* is used to integrate the sensors.
**Exemplary Configuration File**
```typescript
/** Define TinkerForge Elements */
const _conf = {
/** Distance Z-Axis-Right */
'xtL': { // Bricklet ID
nameToPublish: 'printer-01.z-axis-right.distance', // The used topic to publish values
initalActionsToPerform: [ // Array containing Function which should
// be performed after a sussfull initialization
{
funcName: 'setFrequency', // Name of the Function
params: { // Parameters of the Function
frequency: 50
}
}
]
},
/** Acceleration Bricklet. */
'Cff': {
nameToPublish: 'printer-01.z-axis-right.acceleration',
initalActionsToPerform: [
{
funcName: 'setConfiguration',
/** see the Documentation */
params: {
dataRate: 6,
fullScale: 2,
filterBandwith: 2
},
}, {
funcName: 'setFrequency',
params: {
frequency: 50
}
}
]
},
/** DI-Bricklet */
'CmJ': {
nameToPublish: 'printer-01',
initalActionsToPerform: [],
config: [
/** Port 0 => Z-Right Home */
{ name: 'z-axis-right.homed' },
/** Port 1 => Z-Left Home */
{ name: 'z-axis-left.homed' },
/** Port 2 => Y-Home */
{ name: 'y-axis.homed' },
/** Port 3 => X-Home */
{ name: 'x-axis.homed' }
]
},
/** Humidity Bricklet */
'Deu': {
nameToPublish: 'printer-01.environment.humidity',
initalActionsToPerform: [
{
funcName: 'setFrequency',
params: {
frequency: 2
}
}
]
},
/** Temperature Bricklet */
'zgi': {
nameToPublish: 'printer-01.environment.temperature',
initalActionsToPerform: [
{
funcName: 'setFrequency',
params: {
frequency: 2
}
}
]
},
/** Distance IR-Bricklet */
'xuz': {
nameToPublish: 'printer-01.z-axis-left.distance',
initalActionsToPerform: [
{
funcName: 'setFrequency',
params: {
frequency: 50
}
}]
},
/** Imu-Brick */
'6kNLWU': {
nameToPublish: 'printer-01.base',
initalActionsToPerform: [{
funcName: 'setFrequency',
params: {
frequency: 10
}
}]
},
/** Thermocouple Bricklet*/
'Buc': {
nameToPublish: 'printer-01.nozzle.temperature',
initalActionsToPerform: [
{
funcName: 'setFrequency',
params: {
frequency: 10
}
}]
},
/** Input for the Home Positions */
'CLh': {
nameToPublish: 'printer-01',
initalActionsToPerform: [],
config: [
/** Setting Port 0 */
{ name: 'z-axis-right.homed', equation: (_val) => _val > 3.5 },
/** Setting Port 1 */
{ name: 'y-axis.homed', equation: (_val) => _val > 3.5 }
]
},
};
```
**Setting up the configuration**
```typescript
/** Transmitt Configuration */
_connectorPOE.createDevices(generateDescription(_conf));
_connectorUSB.createDevices(generateDescription(_conf));
```