monitor.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* monitor.js
  2. *
  3. * Copyright (C) 2024 kosmospredanie, efosmark, shyzus
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. export class Monitor {
  19. constructor(variant) {
  20. let unpacked = variant.unpack();
  21. this.connector = unpacked[0].unpack()[0].unpack();
  22. let modes = unpacked[1].unpack();
  23. for (let mode_idx in modes) {
  24. let mode = modes[mode_idx].unpack();
  25. let id = mode[0].unpack();
  26. let mode_props = mode[6].unpack();
  27. if ('is-current' in mode_props) {
  28. let is_current = mode_props['is-current'].unpack().get_boolean();
  29. if (is_current) {
  30. this.current_mode_id = id;
  31. break;
  32. }
  33. }
  34. }
  35. let props = unpacked[2].unpack();
  36. if ('is-underscanning' in props) {
  37. this.is_underscanning = props['is-underscanning'].unpack().get_boolean();
  38. } else {
  39. this.is_underscanning = false;
  40. }
  41. if ('is-builtin' in props) {
  42. this.is_builtin = props['is-builtin'].unpack().get_boolean();
  43. } else {
  44. this.is_builtin = false;
  45. }
  46. }
  47. }