diff --git a/ansible_deploy/conf.j2 b/ansible_deploy/conf.j2 index 56a9b80..4ee44a7 100644 --- a/ansible_deploy/conf.j2 +++ b/ansible_deploy/conf.j2 @@ -1,38 +1,30 @@ -[global] -room = "{{ room }}" -mqttIp = "{{ mqtt_ip }}" -mqttPort = "{{ mqtt_port }}" + Hostname: {{ ansible_facts['hostname'] }} running {{ansible_facts['distribution'] }} on address {{ addr }} +Connected projectors: {{ barco_G62[0].ip }} -{% if barco_G62 is defined %} +[global] +room = {{ room }} +mqttIp = {{ mqtt_ip }} +mqttPort = {{ mqtt_port }} + +{% if barco_G62 %} {%+ for projector in barco_G62 +%} [{{projector.model}}.{{projector.position}}] -ip = "{{projector.ip}}" +ip = {{projector.ip}} port = {{projector.port}} {% endfor %} {% endif %} -{%+ if tse_box is defined +%} -serial_device = "{{ tse_box.serial_device }}" +{%+ if tse_box +%} +serial_device = {{ tse_box.serial_device }} {% endif %} -{%+ if projector_motors is defined +%} {# change to appropriate thingy for running them #} -{%+ for motor in projector_motors +%} -[projector_motors.{{motor.position}}] -i2c_address = {{motor.i2c_address}} -{% endfor %} -{% endif %} +{%+ if projector_motors +%} {# change to appropriate thingy for running them #} +{% end if %} -{%+ if extron_audio is defined +%} +{%+ if extron_audio +%} {% endif %} -{%+ if extron_video is defined +%} +{%+ if extron_video +%} -{% endif %} - -{%+ if lucke is defined +%} -[lucke] -url = "{{ lucke.url }}" -roomId = "{{ lucke.roomId }}" -bearer_token = "{{ lucke.bearer_token }}" {% endif %} \ No newline at end of file diff --git a/ansible_deploy/inventory.yml b/ansible_deploy/inventory.yml index 121412d..5f52909 100644 --- a/ansible_deploy/inventory.yml +++ b/ansible_deploy/inventory.yml @@ -10,12 +10,14 @@ P01: - position: main model: barco_G62 port: 3023 - ip: localhost #for testirovanje - # ip: 192.168.192.13 - # - position : side - # model: barco_G62 - # port: 3023 - # ip: 192.168.192.14 - tse_box: - serial_device: /dev/ttyUSB0 + ip: 192.168.192.13 + - position : side + model: barco_G62 + port: 3023 + ip: 192.168.192.14 + + barco_old: + main_ip: 1.1.1.1 + +P22: \ No newline at end of file diff --git a/ansible_deploy/malinca.yml b/ansible_deploy/malinca.yml deleted file mode 100644 index edf453a..0000000 --- a/ansible_deploy/malinca.yml +++ /dev/null @@ -1,38 +0,0 @@ -P01: - hosts: - #10.32.50.170: - 192.168.192.42 - vars: - static_ip: 192.168.192.42 - static_mask: 24 - static_routers: 192.168.192.1 - static_nameservers: 192.168.192.1 - room: P01 - mqtt_ip: localhost - mqtt_port: 1883 - - barco_G62: - - position: main - model: barco_G62 - port: 3023 - # ip: localhost #for testirovanje - ip: 192.168.192.12 - - position : side - model: barco_G62 - port: 3023 - ip: 192.168.192.13 - tse_box: - serial_device: /dev/ttyUSB0 - - projector_motors: - - position: main - i2c_address: 0x42 - offset: 0 #for when using single 8 channel relay board - - position: side - i2c_address: 0x43 - offset: 4 - - lucke: - url: http://192.168.190.90:8091/rest/fri-fkkt/lecture-halls/{roomId}/scenes/{sceneId}/activate - roomId: 0 - bearer_token: 0954afe1-4111-4f89-a123-fea08a55dc46 diff --git a/ansible_deploy/playbook.yaml b/ansible_deploy/playbook.yaml index cb79108..626b8f2 100644 --- a/ansible_deploy/playbook.yaml +++ b/ansible_deploy/playbook.yaml @@ -1,67 +1,49 @@ -- name: Test playbook - vars: - # TODO: maybe don't hardcode this? - PROJECT_BASE: "/home/kat/Documents/polzp/fri_multimedia_rework" +- name: test playbook hosts: P01 - # vars_files: + #vars_files: # - secret - - # addr: "192.168.122.245" - - handlers: - - name: restart NM - ansible.builtin.service: - name: NetworkManager - state: restarted + vars: + addr: "192.168.122.245" + os_environment: + - key: VITE_MQTT_HOST + value: polztest.local tasks: - - name: Ping hosts + - name: ping hosts ansible.builtin.ping: - - - - name: set eth0 static IP - become: true - community.general.nmcli: - conn_name: "Multimedia network" - ifname: eth0 - type: ethernet - ip4: "{{ static_ip }}/{{ static_mask }}" - gw4: "{{ static_routers }}" - state: present - #notify: restart NM - - - name: Install pkgs + - name: install pkgs become: true + #become_user: root apt: name: - - python3-pip - mosquitto + - python3-poetry + #- npm - nginx state: latest - - - name: pip install - pip: - break_system_packages: true - name: - - poetry - - - name: check for script directory + #- name: set env + + - name: ensures services dir exists file: - path: "/home/pi/pyServices" + path: "/home/kat/pyServices" state: directory + - name: ensures services dir exists + file: + path: "/home/kat/pyServices/fri-mm-maline" + state: directory - - name: Copy poetry conf - #become: true + - name: Copy poetry + become: true ansible.builtin.copy: #seuser: root src: "../{{ item }}" - dest: "/home/pi/pyServices/{{ item }}" - owner: pi - group: pi + dest: "/home/kat/pyServices/fri-mm-maline/{{ item }}" + owner: kat + group: kat mode: '0644' backup: yes loop: @@ -69,19 +51,13 @@ - pyproject.toml - README.md - - - name: template config.toml - ansible.builtin.template: - src: ./conf.j2 - dest: /home/pi/pyServices/malinaConfig.toml - - name: copy python scripts - #become: true + become: true ansible.builtin.copy: src: "../{{ item }}" - dest: "/home/pi/pyServices" - owner: pi - group: pi + dest: "/home/kat/pyServices/fri-mm-maline" + owner: kat + group: kat mode: '0644' backup: yes loop: @@ -91,88 +67,30 @@ - projector_motors/projector_motors.py - tse_serial/tse_serial_controler.py - tse_serial/tse_serial_interpreter.py - - lucke/luckeControl.py - # - config.toml # bruh - + - config.toml #TODO GENERATE CONFIG - - name: poetry installation + + - name: poetry installation from thing ansible.builtin.shell: cmd: "poetry install" - chdir: "/home/pi/pyServices" + chdir: "/home/kat/pyServices/fri-mm-maline" - - name: mosquitto service and reload + - name: Copy barco config become: true - ansible.builtin.systemd_service: - name: mosquitto.service - state: restarted - daemon_reload: true - - - - name: generate systemd services - become: true - block: - - name: barco services - when: barco_G62 is defined - block: - - name: template service - vars: - script_file: "/home/pi/pyServices/barco_G62_control.py %i" - ansible.builtin.template: - src: ./service.j2 - dest: /lib/systemd/system/barco@.service - - name: enable service - ansible.builtin.systemd_service: - name: "{{item}}" - enabled: true - state: restarted - loop: - - barco@main.service - - barco@side.service - - - name: template projector motors service - when: projector_motors is defined - block: - - name: template service - vars: - script_file: "/home/pi/pyServices/projector_motors.py" - ansible.builtin.template: - src: ./service.j2 - dest: /lib/systemd/system/projector_motors.service - - name: enable service - ansible.builtin.systemd_service: - name: projector_motors.service - enabled: true - state: restarted - - - name: template tse serial box service - when: tse_box is defined - block: - - name: template service - vars: - script_file: "/home/pi/pyServices/tse_serial_controler.py" - ansible.builtin.template: - src: ./service.j2 - dest: /lib/systemd/system/tse_box.service - - name: enable service - ansible.builtin.systemd_service: - name: tse_box.service - enabled: true - state: restarted - - - name: template lucke service - when: lucke is defined - block: - - name: tmeplate service - vars: - script_file: "/home/pi/pyServices/luckeControl.py" - ansible.builtin.template: - src: ./service.j2 - dest: /lib/systemd/system/lucke.service - - name: enable service - ansible.builtin.systemd_service: - name: lucke.service - enabled: true - state: restarted + ansible.builtin.copy: + #seuser: root + src: "../{{ item }}" + dest: /lib/systemd/system + owner: root + group: root + mode: '0644' + #backup: yes + loop: + - barco@.service + - extron_audio.service + - mqtt_init.service + - projector_motors.service + - tse_box.service @@ -187,25 +105,48 @@ mode: '0644' backup: yes - - - name: Build frontend - delegate_to: localhost - command: - chdir: "{{PROJECT_BASE}}/frontend/vju_display/" - cmd: "npm run build" + # - name: set env + # become: true + # ansible.builtin.lineinfile: + # dest: "/etc/environment" + # state: present + # regexp: "^{{ item.key }}=" + # line: "{{ item.key }}={{ item.value }}" + # with_items: "{{ os_environment }}" - name: copy frontend to webroot become: true ansible.builtin.copy: - src: "{{PROJECT_BASE}}/frontend/vju_display/dist/" - dest: /var/www/html/ + src: /home/kat/Documents/polzp/fri_multimedia_rework/frontend/vju_display/dist + #src: /home/kat/fri_multimedia_rework/frontend/vju_display/dist + #remote_src: true + dest: /srv/www + #dest: /home/kat/testoa owner: root - group: www-data + group: root mode: '0755' backup: yes - - name: daemon reload + - name: enable modules become: true ansible.builtin.systemd_service: - daemon_reload: true + #name: "{{[ 'barco@main.service', 'barco@side.service' ]}}" + name: "{{ item }}" + state: stopped + enabled: false + loop: + - barco@main.service + - barco@side.service + - extron_audio.service + - mqtt_init.service + - projector_motors.service + - tse_box.service + + + - name: mosquitto service and reload + become: true + ansible.builtin.systemd_service: + name: mosquitto.service + state: started + daemon_reload: true \ No newline at end of file diff --git a/ansible_deploy/service.j2 b/ansible_deploy/service.j2 index b232bbc..032e0ae 100644 --- a/ansible_deploy/service.j2 +++ b/ansible_deploy/service.j2 @@ -3,13 +3,12 @@ Description={{ script_file }} After=multi-user.target [Service] -ExecStart=/usr/local/bin/poetry run python3 -u {{ script_file }} +ExecStart=/usr/bin/poetry run /usr/bin/python3 {{ script_file }} Type=simple Restart=always -User=pi -Group=pi +User=kat +Group=kat RestartSec=10 -WorkingDirectory=/home/pi/pyServices [Install] WantedBy=multi-user.target diff --git a/ansible_deploy/testbook.yaml b/ansible_deploy/testbook.yaml index 1082599..9795070 100644 --- a/ansible_deploy/testbook.yaml +++ b/ansible_deploy/testbook.yaml @@ -11,7 +11,7 @@ tasks: - name: test things - when: barco_G62 is defined + when: barco_g62 is defined block: #- name: ping hosts # ansible.builtin.ping: @@ -19,13 +19,13 @@ - name: template config.toml ansible.builtin.template: src: ./conf.j2 - dest: /home/pi/conf.toml + dest: /home/kat/testo/conf.txt - name: template barco systemd service vars: script_file: "/home/kat/pyServices/fri-mm-maline/barco_G62_control.py %i" ansible.builtin.template: src: ./service.j2 - dest: /home/kat/testo/barco.service + dest: /home/kat/testo/barc.serv - name: enable barcos ansible.builtin.ping: #itd itd itd @@ -34,5 +34,4 @@ block: - name: pingerino ansible.builtin.ping: - diff --git a/barco_rlmw_http/barco_rlwm_http.py b/barco_rlmw_http/barco_rlwm_http.py deleted file mode 100644 index 04327e7..0000000 --- a/barco_rlmw_http/barco_rlwm_http.py +++ /dev/null @@ -1,67 +0,0 @@ -import re -import asyncio -import aiohttp -from asyncio.exceptions import CancelledError - -PORT = 43680 -RE_STATUS = re.compile(r".stats.txt(.+).value='(.+)';") -REMOTEKEY_TIMEOUT = aiohttp.ClientTimeout(total=1) - - -class BarcoRLM_Control: - def __init__(self, projector_ip): - self.projector_ip = projector_ip - self.session = None - - async def _request(self, method, path, *args, **kwargs): - if not self.session: - self.session = aiohttp.ClientSession() - url = f"http://{self.projector_ip}{path}" - resp = await self.session.request(method, url, *args, **kwargs) - resp.raise_for_status() - return await resp.text() - - async def get_status(self): - resp = await self._request("GET", "/tgi/firststatus.tgi") - matches = RE_STATUS.findall(resp) - status = dict(matches) - return status - - async def toggle_power(self): - await self._request("GET", "/tgi/general.tgi?powertog") - - async def click_remote(self, key): - try: - await self._request("GET", f"/tgi/remote.tgi?{key}", timeout=REMOTEKEY_TIMEOUT, raise_for_status=False) - except TimeoutError: - pass - - async def set_shutter(self, shutter): - endpoint = f"/tgi/general.tgi?pause{onoff(shutter)}" - await self._request("GET", endpoint) - - async def set_power(self, power): - key = onoff(power) + "ky" - await self.click_remote(key) - - async def set_input(self, input): - endpoint = f"/tgi/input.tgi?{input}" - await self._request("GET", endpoint) - - -def onoff(state: bool) -> str: - if state: - return "on" - else: - return "off" - -if __name__ == "__main__": - - async def main(): - barco = BarcoRLM_Control("192.168.192.12") - status = await barco.get_status() - print(status) - - await barco.click_remote("kymenu") - - asyncio.run(main()) diff --git a/barco_rlmw_http/main.py b/barco_rlmw_http/main.py deleted file mode 100644 index 1eca653..0000000 --- a/barco_rlmw_http/main.py +++ /dev/null @@ -1,80 +0,0 @@ -import asyncio -import aiomqtt -from collections import defaultdict - -from barco_legacy import BarcoRLM_Control - -# TODO MAKE THIS CONFIGURALBE -PROJECTOR_IP = "192.168.192.12" -MQTT_PREFIX = "p22/projektorji/glavni" -MQTT_HOST = "-----" -POLLING_PERIOD_SEC = 10 - - -class BarcoRLM_MQTT: - def __init__(self, projector_ip, mqtt_prefix): - self.projector_ip = projector_ip - self.mqtt_prefix = mqtt_prefix - self.barco = BarcoRLM_Control(projector_ip) - self.last_status = defaultdict(lambda: '') - - async def run(self): - async with aiomqtt.Client(MQTT_HOST, 1883) as client: - self.client = client - task_polling = asyncio.create_task(self.task_polling()) - task_control = asyncio.create_task(self.task_control()) - await asyncio.gather(task_control, task_polling) - - async def task_control(self): - topicMatch = f"{self.mqtt_prefix}/ukaz/+" - await self.client.subscribe(topicMatch) - - async for mesg in self.client.messages: - cmd = mesg.topic.value.split("/")[-1] - val = mesg.payload.decode() - - if cmd == "power": - await self.barco.set_power(onoff(val)) - elif cmd == "shutter": - await self.barco.set_shutter(onoff(val)) - - async def task_polling(self): - while True: - status = await self.barco.get_status() - for key, val in status.items(): - if self.last_status[key] != val: - print(f"Status change {key}={val}") - await self.on_status_change(key, val) - - self.last_status = status - await asyncio.sleep(POLLING_PERIOD_SEC) - - async def on_status_change(self, key, val): - mkey = mval = None - if key == "status": - mkey = "power" - if val == "Imaging": - mval = "1" - if val == "Standby": - mval = "0" - if key == "src": - mkey = "input" - mval = val - if key == "fmr": - mkey = "input_format" - mval = val - if mkey is not None and mval is not None: - await self.client.publish(f"{self.mqtt_prefix}/status/{mkey}", payload=mval) - - -def onoff(input): - #if input == "1": - # return True - #elif input == "0": - # return False - return input == "1" - - -if __name__ == '__main__': - barco = BarcoRLM_MQTT(PROJECTOR_IP, MQTT_PREFIX) - asyncio.run(barco.run()) diff --git a/barco_rlmw_tcp/barco_rlmw_tcp.py b/barco_rlmw_tcp/barco_rlmw_tcp.py deleted file mode 100644 index 8d38ea6..0000000 --- a/barco_rlmw_tcp/barco_rlmw_tcp.py +++ /dev/null @@ -1,98 +0,0 @@ -import re -import asyncio -import telnetlib3 -from dataclasses import dataclass -from enum import StrEnum - -PORT = 43680 -RE_STATUS = re.compile(r"OP (.+?)(?:$| = (.+)$)") - - -@dataclass(frozen=True) -class ACK: - command: str - -@dataclass(frozen=True) -class ValueUpdate: - key: str - value: str - -class Status(StrEnum): - standby = "0" - warmup = "1" - imaging = "2" - cooling = "3" - warning = "4" - -class LampMode(StrEnum): - economy = "0" - standard = "1" - dimming = "2" - -class ValueType(StrEnum): - status = "status" - picture_mute = "picture.mute" - lamp_mode = "lamp.mode" - - -class BarcoRLMW_TCP: - def __init__(self, projector_ip): - self.projector_ip = projector_ip - self.session = None - - async def init(self): - self.reader, self.writer = await telnetlib3.open_connection(self.projector_ip, 3023) - - async def exec(self, cmd): - await self.writer.write("op " + cmd + "\r") - - async def set(self, key, val): - await self.writer.write("op " + key + " = " + val + "\r") - - async def query(self, key): - await self.writer.write("op " + key + " ?\r") - - async def set_power(self, power): - await self.exec(f"power.{onoff(power)}") - - async def set_shutter(self, shutter): - await self.set("picture.mute", int(shutter)) - - async def iter_messages(self): - """Async iterator that processes feedback from the projector. - Yields ACK (acknowledgement) and ValueUpdate (value has changed) messages.""" - while True: - line = await self.reader.readuntil('\r').decode().strip() - msg = self.parse_response(line) - if msg: - yield msg - - def parse_response(self, line): - matches = RE_STATUS.findall(line) - - if len(matches) == 0: - return None - match = matches[0] - - if len(match) == 2: - return ACK(match[1]) - if len(match) == 3: - return ValueUpdate(match[1], match[2]) - - -def onoff(state: bool) -> str: - if state: - return "on" - else: - return "off" - -if __name__ == "__main__": - - async def main(): - barco = BarcoRLMW_TCP("192.168.192.12") - status = await barco.get_status() - print(status) - - await barco.click_remote("kymenu") - - asyncio.run(main()) diff --git a/barco_rlmw_tcp/main.py b/barco_rlmw_tcp/main.py deleted file mode 100644 index 04eb690..0000000 --- a/barco_rlmw_tcp/main.py +++ /dev/null @@ -1,72 +0,0 @@ -import asyncio -import aiomqtt -from collections import defaultdict - -from barco_rlmw_tcp import BarcoRLMW_TCP, ValueUpdate, Status, ACK, ValueType - -# TODO MAKE THIS CONFIGURALBE -PROJECTOR_IP = "192.168.192.12" -MQTT_PREFIX = "p22/projektorji/glavni" -MQTT_HOST = "-------" -POLLING_PERIOD_SEC = 10 - - -class BarcoRLMW_TCP_MQTT: - def __init__(self, projector_ip, mqtt_prefix): - self.projector_ip = projector_ip - self.mqtt_prefix = mqtt_prefix - self.barco = BarcoRLMW_TCP(projector_ip) - self.last_status = defaultdict(lambda: '') - - async def run(self): - async with aiomqtt.Client(MQTT_HOST, 1883) as client: - self.client = client - task_polling = asyncio.create_task(self.task_polling()) - task_control = asyncio.create_task(self.task_control()) - await asyncio.gather(task_control, task_polling) - - async def task_control(self): - topicMatch = f"{self.mqtt_prefix}/ukaz/+" - await self.client.subscribe(topicMatch) - - async for mesg in self.client.messages: - cmd = mesg.topic.value.split("/")[-1] - val = mesg.payload.decode() - - if cmd == "power": - await self.barco.set_power(onoff(val)) - elif cmd == "shutter": - await self.barco.set_shutter(onoff(val)) - - async def task_polling(self): - while True: - await self.barco.query("status") - await asyncio.sleep(POLLING_PERIOD_SEC) - - async def write_status(self, status, value): - await self.client.publish(f"{self.mqtt_prefix}/status/{status}", payload=value) - - async def task_process_messages(self): - async for msg in self.barco.iter_messages(): - # We only care about value updates - if isinstance(msg, ValueUpdate): - # Power status - if msg.key == ValueType.status: - if msg.value in (Status.imaging, Status.warmup): - self.write_status("power", 1) - elif msg.value in (Status.standby, Status.cooling): - self.write_status("power", 0) - # Video mute - if msg.key == ValueType.picture_mute: - self.write_status("shutter", msg.value) - -def onoff(input): - if input == "1": - return True - elif input == "0": - return False - - -if __name__ == '__main__': - barco = BarcoRLMW_TCP_MQTT(PROJECTOR_IP, MQTT_PREFIX) - asyncio.run(barco.run()) diff --git a/barco_telnet/barco_G62_control.py b/barco_telnet/barco_G62_control.py index 14031c1..aa02039 100644 --- a/barco_telnet/barco_G62_control.py +++ b/barco_telnet/barco_G62_control.py @@ -7,13 +7,12 @@ import sys #GLOBALS -room: str -barcoPosition: str -barcoIP: str -telnetPort: int -mqttPort: int -mqttIP: str -barcoReached: bool +room = "undefined" +position = "undefined" +barcoIP = "undefined" +telnetPort = 3023 +mqttPort = 1883 +mqttIP = 'localhost' cmdMap = { 'power': 'POWR', @@ -24,25 +23,23 @@ reverseCmdMap = {v: k for k, v in cmdMap.items()} def parse_barco_response(raw: str): - global room, barcoPosition, barcoReached raw = raw[1:-1] # strip square brackets #print(raw) if raw.startswith("ERR"): - print("Projector" + room + " " + barcoPosition + " returned" + raw) return None # TODO parse type error - "disabled control" is special case which shouldnt normally happen cmd, status = raw.split("!", maxsplit=2) #print(cmd + " " + status) cmd = reverseCmdMap[cmd] status = '1' if status == '01' else '0' - barcoReached = True return cmd, status +#TODO MAKE THESE USE GLOBAL INSTEAD OF PASSING BARCO POSITION IN MAIN async def barco_telnet_command(client, writer, select: str): global room onSub = f"{room}/projectors/{select}/#" #print('TEST', onSub) - onMatch = f"{room}/projectors/{select}/command/+" #TODO should be set? + onMatch = f"{room}/projectors/{select}/command/+" await client.subscribe(onSub) #async with client.messages as msgs: async for mesg in client.messages: @@ -68,7 +65,7 @@ async def barco_telnet_read_status(client, reader, select: str): raw_response: str = output.decode().strip() # strip not necessary? needed for local netcat testing though print("Received: " + raw_response + " from Barco (" + select + ')') parsed = parse_barco_response(raw_response) - if parsed is None: + if parsed == None: continue #TODO alert for errors print(f"Updating topic [{parsed[0]}] with value [{parsed[1]}]") await client.publish(f"{room}/projectors/{select}/status/{parsed[0]}", payload=parsed[1]) @@ -81,7 +78,7 @@ async def barco_telnet_query_status(writer, select: str): writer.write(f"[{val}?]" + '\r\n') # TODO test if funny CRLF necessary (it probably gets ignored) await asyncio.sleep(0.2) # sleep between writes necessary, otherwise it gets confused. # simultaneous commands from control could break this? TODO fix later - await asyncio.sleep(10) # TODO find appropriate period + await asyncio.sleep(30) # TODO find appropriate period # async def shell(reader, writer): @@ -93,37 +90,25 @@ async def barco_telnet_query_status(writer, select: str): async def main(): - global room, barcoReached global barcoPosition, barcoIP, telnetPort, mqttIP, mqttPort if len(sys.argv) < 2: sys.exit("No position provided") else: barcoPosition = sys.argv[1] - conf = toml.load('./malinaConfig.toml') - g62Barcos = {k: v for k,v in conf["barco_G62"].items()} - currentBarco = g62Barcos[barcoPosition] + conf = toml.load('./config.toml') + g62Barcos = {k: v for k,v in barcos["barco_G62"].items()} + currentBarco = newBarcos[barcoPosition] barcoIP = currentBarco['ip'] - telnetPort = int(currentBarco["port"]) - room = conf["global"]["room"] - mqttPort = int(conf["global"]["mqttPort"]) - mqttIP = conf["global"]["mqttIp"] - barcoReached = False - try: - barcoReader, barcoWriter = await telnetlib3.open_connection(barcoIP, telnetPort) - barcoReached = True - except Exception as e: - print("Connection failed: " + barcoIP + ": " + str(e)) - barcoReached = False - finally: - async with aiomqtt.Client(mqttIP, mqttPort) as client: - task_status_query_barco = asyncio.create_task(barco_telnet_query_status(barcoWriter, barcoPosition)) - task_status_reader_barco = asyncio.create_task(barco_telnet_read_status(client, barcoReader, barcoPosition)) - task_control_barco = asyncio.create_task(barco_telnet_command(client, barcoWriter, barcoPosition)) + barcoReader, barcoWriter = await telnetlib3.open_connection(barcoIP, telnetPort) + async with aiomqtt.Client(mqttIP, mqttPort) as client: + task_status_query_barco = asyncio.create_task(barco_telnet_query_status(barcoWriter, barcoPosition)) + task_status_reader_barco = asyncio.create_task(barco_telnet_read_status(client, barcoReader, barcoPosition)) + task_control_barco = asyncio.create_task(barco_telnet_command(client, barcoWriter, barcoPosition)) + + await asyncio.gather(task_status_query_barco, task_status_reader_barco, task_control_barco) - await asyncio.gather(task_status_query_barco, task_status_reader_barco, task_control_barco) - await client.publish(f"{room}/projectors/{barcoPosition}/error", payload=("UNREACHABLE" if not barcoReached else "OK")) ### fuj to, ne tk delat diff --git a/docs/multimedia_ip.csv b/docs/multimedia_ip.csv index 485223e..1228aca 100644 --- a/docs/multimedia_ip.csv +++ b/docs/multimedia_ip.csv @@ -1,6 +1,5 @@ Prostor,Naprava,Model,IPv4,Naslov -,Multimedija server,,192.168.192.9,multimedija.fri1.uni-lj.si -P01,Malinca,Raspberry Pi 5,192.168.192.42, P01,Crestron krmilnik,Crestron AV3,192.168.192.10, P01,Crestron tablica,Crestron TSW550,192.168.192.11, P01,Glavni projektor,Barco G62,192.168.192.12, diff --git a/frontend/vju_display/src/App.vue b/frontend/vju_display/src/App.vue index 32334e9..d5fb340 100644 --- a/frontend/vju_display/src/App.vue +++ b/frontend/vju_display/src/App.vue @@ -1,48 +1,47 @@ diff --git a/frontend/vju_display/src/assets/base.css b/frontend/vju_display/src/assets/base.css new file mode 100644 index 0000000..8ea68d2 --- /dev/null +++ b/frontend/vju_display/src/assets/base.css @@ -0,0 +1,32 @@ +*, +*::before, +*::after { + box-sizing: border-box; + margin: 0; + font-weight: normal; +} + +:root { + --color-text: #000; + --color-background: #EEE; + + --color-brand-ul-red: #e03127; + --color-brand-ul-light-grey: #E6E7E8; + --color-brand-ul-medium-grey: #A7A8AA; + --color-brand-ul-dark-grey: #58595b; +} + +body { + min-height: 100vh; + color: var(--color-text); + background: var(--color-background); + transition: + color 0.5s, + background-color 0.5s; + line-height: 1.6; + font-family: sans-serif; + font-size: 17px; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} diff --git a/frontend/vju_display/src/assets/main.css b/frontend/vju_display/src/assets/main.css index f43dca1..13c87d0 100644 --- a/frontend/vju_display/src/assets/main.css +++ b/frontend/vju_display/src/assets/main.css @@ -1,47 +1,7 @@ -*, -*::before, -*::after { - box-sizing: border-box; - margin: 0; - font-weight: normal; -} - -:root { - --color-text: #000; - --color-background: #EEE; - - --color-brand-ul-red: #e03127; - --color-brand-ul-light-grey: #E6E7E8; - --color-brand-ul-medium-grey: #A7A8AA; - --color-brand-ul-dark-grey: #58595b; -} - -body { - min-height: 100vh; - color: var(--color-text); - background: var(--color-background); - transition: - color 0.5s, - background-color 0.5s; - line-height: 1.6; - font-family: "Noto Sans", sans-serif; - font-size: 17px; - text-rendering: optimizeLegibility; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - - -* { - user-select: none; -} -html, body { - touch-action: manipulation; -} +@import './base.css'; #app { max-width: 1280px; - height: 100vh; margin: 0 auto; } @@ -66,46 +26,12 @@ a, } } - -.mstatus { - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; -} - -button { - background: lightgray; - font-size: 1.3em; - font-weight: bold; -} - -button:focus:not(:active) { - background: lightgray; -} - -button:focus-visible(:active) { - background: gray; -} - - - button { border: none; - background-color: lightgray; + background-color: #aaa; + cursor: pointer; } -button:active { - background: gray; +button:hover, button:focus, button:active { + background-color: #ccc; } - - -h1 { - text-align: center; -} -h3 { - font-weight: bold; -} - -.currentlyActive { - background-color: orange !important -} \ No newline at end of file diff --git a/frontend/vju_display/src/components/AudioControlModule.vue b/frontend/vju_display/src/components/AudioControlModule.vue deleted file mode 100644 index eafb029..0000000 --- a/frontend/vju_display/src/components/AudioControlModule.vue +++ /dev/null @@ -1,85 +0,0 @@ - - - - - diff --git a/frontend/vju_display/src/components/LectureModule.vue b/frontend/vju_display/src/components/LectureModule.vue index 3c00fc2..627c7cb 100644 --- a/frontend/vju_display/src/components/LectureModule.vue +++ b/frontend/vju_display/src/components/LectureModule.vue @@ -1,58 +1,48 @@ diff --git a/frontend/vju_display/src/components/Lift.vue b/frontend/vju_display/src/components/Lift.vue index de00b71..8dea428 100644 --- a/frontend/vju_display/src/components/Lift.vue +++ b/frontend/vju_display/src/components/Lift.vue @@ -1,14 +1,14 @@ - - - - diff --git a/frontend/vju_display/src/components/Numpad.vue b/frontend/vju_display/src/components/Numpad.vue deleted file mode 100644 index 285d427..0000000 --- a/frontend/vju_display/src/components/Numpad.vue +++ /dev/null @@ -1,125 +0,0 @@ - - - - - diff --git a/frontend/vju_display/src/components/Platno.vue b/frontend/vju_display/src/components/Platno.vue index 95aebdd..118f31d 100644 --- a/frontend/vju_display/src/components/Platno.vue +++ b/frontend/vju_display/src/components/Platno.vue @@ -1,15 +1,15 @@ diff --git a/frontend/vju_display/src/components/ProjectorPowerModule.vue b/frontend/vju_display/src/components/ProjectorPowerModule.vue deleted file mode 100644 index 92151a1..0000000 --- a/frontend/vju_display/src/components/ProjectorPowerModule.vue +++ /dev/null @@ -1,87 +0,0 @@ - - - - - diff --git a/frontend/vju_display/src/components/Projektor.vue b/frontend/vju_display/src/components/Projektor.vue index bb24a36..38f8e71 100644 --- a/frontend/vju_display/src/components/Projektor.vue +++ b/frontend/vju_display/src/components/Projektor.vue @@ -7,18 +7,15 @@ import { $mqtt } from 'vue-paho-mqtt' const props = defineProps({ room: String, position: String, - ctrltype: [String, null] + ctrlType: [String, null] }) const topicstrs = [ //TODO everything else props.room + '/projectors/' + props.position + '/status/power', props.room + '/projectors/' + props.position + '/status/shutter', props.room + '/projectors/' + props.position + '/status/freeze', - props.room + '/projectors/' + props.position + '/status', ] -const isUnreachable = ref(false) - const subscriptions = topicstrs.map(topic => { // console.log('subbing to', topic) @@ -30,12 +27,10 @@ const subscriptions = function handleIncomingMQTT(topic: string, msg: string) { console.log('Received on', topic, 'with message', msg) - if (topic.includes('status') && !topic.endsWith('status')) { + if (topic.includes('status')) { //console.log(topic.split('/')) let typ = topic.split('/')[4] handleProjectorStatus(typ, msg) - } else { - isUnreachable.value = msg.length > 1 } } @@ -56,7 +51,7 @@ onMounted(() => { function publishMQTTMsg(topic: string, msg: string) { //msg = msg.toString() console.log('Sending to [', topic, '] with message [', msg, ']') - $mqtt.publish(topic, msg, 'Fnr') //todo refactor to 1 or 0 maybe + $mqtt.publish(topic, msg, 'Qr') //todo refactor to 1 or 0 maybe console.log('sent') } @@ -76,21 +71,20 @@ const projStatus = reactive({ \ No newline at end of file diff --git a/frontend/vju_display/src/components/pages/ServisPage.vue b/frontend/vju_display/src/components/pages/ServisPage.vue index a344fad..574724a 100644 --- a/frontend/vju_display/src/components/pages/ServisPage.vue +++ b/frontend/vju_display/src/components/pages/ServisPage.vue @@ -1,76 +1,37 @@ - - - \ No newline at end of file diff --git a/frontend/vju_display/src/components/pages/VideoPage.vue b/frontend/vju_display/src/components/pages/VideoPage.vue index 08de864..86db1ac 100644 --- a/frontend/vju_display/src/components/pages/VideoPage.vue +++ b/frontend/vju_display/src/components/pages/VideoPage.vue @@ -9,34 +9,27 @@ import Platno from '../Platno.vue' const props = defineProps({ room: String, }) -const _glavni_position = ref('main') -const _stranski_position = ref('side') +const _glavni_position = ref('glavni') +const _stranski_position = ref('stranski') const _test = ref('test') diff --git a/frontend/vju_display/src/components/tabs/Tab.vue b/frontend/vju_display/src/components/tabs/Tab.vue index a4fcc5d..239c705 100644 --- a/frontend/vju_display/src/components/tabs/Tab.vue +++ b/frontend/vju_display/src/components/tabs/Tab.vue @@ -16,6 +16,7 @@ const props = defineProps({ font-weight: bold; } .tab:hover { + cursor: pointer; } diff --git a/frontend/vju_display/src/components/tabs/VerticalTabs.vue b/frontend/vju_display/src/components/tabs/VerticalTabs.vue index 8dfc077..1f64f09 100644 --- a/frontend/vju_display/src/components/tabs/VerticalTabs.vue +++ b/frontend/vju_display/src/components/tabs/VerticalTabs.vue @@ -8,6 +8,7 @@