Small Bree based job runner + gui
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. const { TempSensor, Channel } = require('./sensor')
  2. const { Controller } = require('./controller')
  3. const { Scanner } = require('./scanner')
  4. const unitScale = {
  5. dC: { unit: 'degree', scale: 'celcius' },
  6. dF: { unit: 'degree', scale: 'fahrenheit' },
  7. mV: { unit: 'volt', scale: 'millivolt' },
  8. V: { unit: 'volt', scale: 'volt' }
  9. }
  10. /**
  11. * Create a sensor and readout channel as -67 to 257 degrees fahrenheit
  12. */
  13. const tempController = new Controller({
  14. type: 'temp',
  15. channel: new Channel({ name: 'temperature_channel_00', min: -67, max: 257, interval: 10, unit: unitScale.dF.unit, scale: unitScale.dF.scale }),
  16. sensor: new TempSensor({ name: 'temperature_sensor_00', min: -67, max: 257, interval: 10, unit: unitScale.dF.unit, scale: unitScale.dF.scale })
  17. })
  18. console.log(tempController.readout) // { value: 78, unit: 'degrees' scale: 'fahrenheit' }
  19. /**
  20. * Create a 0-5v sensor and interpolate readout as -67 to 257 degrees fahrenheit
  21. */
  22. const manualTempController = new Controller({
  23. type: 'temp',
  24. channel: new Channel({ name: 'temperature_channel_01', min: -67, max: 257, interval: 10, unit: unitScale.dF.unit, scale: unitScale.dF.scale }),
  25. sensor: new TempSensor({ name: 'temperature_sensor_01', min: 0, max: 5, interval: 100, unit: unitScale.mV.unit, scale: unitScale.mV.scale })
  26. })
  27. console.log(manualTempController.readout) // { value: 78, unit: 'degrees' scale: 'fahrenheit' }
  28. /**
  29. * A Scanner is made up of controllers
  30. * A Controller is made up of an output Channel and input Sensor
  31. */
  32. const mySystem = new Scanner({ controllers: [ tempController, manualTempController ] })
  33. console.log(mySystem.readAll())
  34. /**
  35. * Example: console.log(mySystem.readAll())
  36. * temperature_channel_00: Reading({ value: 78, unit: 'degrees' scale: 'fahrenheit' }),
  37. * temperature_channel_01: Reading({ value: 78, unit: 'degrees' scale: 'fahrenheit' }),
  38. */
  39. module.exports = {
  40. unitScale
  41. }