diff --git a/ansible_deploy/conf.j2 b/ansible_deploy/conf.j2 index 4ee44a7..281fc8a 100644 --- a/ansible_deploy/conf.j2 +++ b/ansible_deploy/conf.j2 @@ -1,30 +1,31 @@ - Hostname: {{ ansible_facts['hostname'] }} running {{ansible_facts['distribution'] }} on address {{ addr }} -Connected projectors: {{ barco_G62[0].ip }} - [global] -room = {{ room }} -mqttIp = {{ mqtt_ip }} -mqttPort = {{ mqtt_port }} +room = "{{ room }}" +mqttIp = "{{ mqtt_ip }}" +mqttPort = "{{ mqtt_port }}" -{% if barco_G62 %} +{% if barco_G62 is defined %} {%+ for projector in barco_G62 +%} [{{projector.model}}.{{projector.position}}] -ip = {{projector.ip}} +ip = "{{projector.ip}}" port = {{projector.port}} {% endfor %} {% endif %} -{%+ if tse_box +%} -serial_device = {{ tse_box.serial_device }} +{%+ if tse_box is defined +%} +serial_device = "{{ tse_box.serial_device }}" {% endif %} -{%+ if projector_motors +%} {# change to appropriate thingy for running them #} -{% end if %} +{%+ 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 extron_audio +%} +{%+ if extron_audio is defined +%} {% endif %} -{%+ if extron_video +%} +{%+ if extron_video is defined +%} {% endif %} \ No newline at end of file diff --git a/ansible_deploy/inventory.yml b/ansible_deploy/inventory.yml index 5f52909..121412d 100644 --- a/ansible_deploy/inventory.yml +++ b/ansible_deploy/inventory.yml @@ -10,14 +10,12 @@ P01: - position: main model: barco_G62 port: 3023 - 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: + 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 \ No newline at end of file diff --git a/ansible_deploy/malinca.yml b/ansible_deploy/malinca.yml new file mode 100644 index 0000000..9a19985 --- /dev/null +++ b/ansible_deploy/malinca.yml @@ -0,0 +1,34 @@ +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 + diff --git a/ansible_deploy/playbook.yaml b/ansible_deploy/playbook.yaml index 626b8f2..1bf9b62 100644 --- a/ansible_deploy/playbook.yaml +++ b/ansible_deploy/playbook.yaml @@ -1,49 +1,64 @@ -- name: test playbook +- name: Test playbook hosts: P01 - #vars_files: + # vars_files: # - secret - vars: - addr: "192.168.122.245" - os_environment: - - key: VITE_MQTT_HOST - value: polztest.local + vars: + # addr: "192.168.122.245" + + handlers: + - name: restart NM + ansible.builtin.service: + name: NetworkManager + state: restarted tasks: - - name: ping hosts + - name: Ping hosts ansible.builtin.ping: - - - name: install pkgs + + + - 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 become: true - #become_user: root apt: name: + - python3-pip - mosquitto - - python3-poetry - #- npm - nginx state: latest - - #- name: set env - - - name: ensures services dir exists - file: - path: "/home/kat/pyServices" - state: directory - - - name: ensures services dir exists - file: - path: "/home/kat/pyServices/fri-mm-maline" - state: directory - - name: Copy poetry - become: true + - name: pip install + pip: + break_system_packages: true + name: + - poetry + + + - name: check for script directory + file: + path: "/home/pi/pyServices" + state: directory + + + - name: Copy poetry conf + #become: true ansible.builtin.copy: #seuser: root src: "../{{ item }}" - dest: "/home/kat/pyServices/fri-mm-maline/{{ item }}" - owner: kat - group: kat + dest: "/home/pi/pyServices/{{ item }}" + owner: pi + group: pi mode: '0644' backup: yes loop: @@ -51,13 +66,19 @@ - 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/kat/pyServices/fri-mm-maline" - owner: kat - group: kat + dest: "/home/pi/pyServices" + owner: pi + group: pi mode: '0644' backup: yes loop: @@ -67,30 +88,91 @@ - projector_motors/projector_motors.py - tse_serial/tse_serial_controler.py - tse_serial/tse_serial_interpreter.py - - config.toml #TODO GENERATE CONFIG + # - config.toml # bruh + - - - name: poetry installation from thing + - name: poetry installation ansible.builtin.shell: cmd: "poetry install" - chdir: "/home/kat/pyServices/fri-mm-maline" + chdir: "/home/pi/pyServices" - - name: Copy barco config + - name: mosquitto service and reload become: true - 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 + ansible.builtin.systemd_service: + name: mosquitto.service + state: started + 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: started + 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: started + + - 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: started + + + + # - name: Copy barco config + # become: true + # 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 @@ -118,35 +200,29 @@ become: true ansible.builtin.copy: - src: /home/kat/Documents/polzp/fri_multimedia_rework/frontend/vju_display/dist + 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: /srv/www + dest: /var/www/html/ #dest: /home/kat/testoa owner: root group: root mode: '0755' backup: yes - - name: enable modules - become: true - ansible.builtin.systemd_service: - #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: enable modules + # become: true + # ansible.builtin.systemd_service: + # #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 032e0ae..133b2f6 100644 --- a/ansible_deploy/service.j2 +++ b/ansible_deploy/service.j2 @@ -3,12 +3,13 @@ Description={{ script_file }} After=multi-user.target [Service] -ExecStart=/usr/bin/poetry run /usr/bin/python3 {{ script_file }} +ExecStart=/usr/local/bin/poetry run python3 {{ script_file }} Type=simple Restart=always -User=kat -Group=kat +User=pi +Group=pi RestartSec=10 +WorkingDirectory=/home/pi/pyServices [Install] WantedBy=multi-user.target diff --git a/ansible_deploy/testbook.yaml b/ansible_deploy/testbook.yaml index 9795070..1082599 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/kat/testo/conf.txt + dest: /home/pi/conf.toml - 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/barc.serv + dest: /home/kat/testo/barco.service - name: enable barcos ansible.builtin.ping: #itd itd itd @@ -34,4 +34,5 @@ block: - name: pingerino ansible.builtin.ping: + diff --git a/frontend/vju_display/src/App.vue b/frontend/vju_display/src/App.vue index d5fb340..1c25081 100644 --- a/frontend/vju_display/src/App.vue +++ b/frontend/vju_display/src/App.vue @@ -7,6 +7,7 @@ import Tab from './components/tabs/Tab.vue'; import LightingPage from './components/pages/LightingPage.vue'; import ServisPage from './components/pages/ServisPage.vue'; + let urlParams = new URLSearchParams(window.location.search); const currentRoom = ref(urlParams.get('room') || 'none') // if no param specified @@ -16,32 +17,16 @@ const currentRoom = ref(urlParams.get('room') || 'none') // if no param specifie const pageNum = ref(0) -const srvcUnlocked = ref(false) +const srvcUnlocked = ref(true) const showPinPopup = ref(false) -function openPinDiag() { -} - -function closePinDiag() { - -} - -function unlockServicePage() { - showPinPopup.value = true - while (true) { - if ('' == '') { - srvcUnlocked.value = true - closePinDiag() - break - } - } -} function lockServicePage() { srvcUnlocked.value = false } + @@ -100,4 +84,8 @@ h1 { padding: .4rem; } +* { +cursor: none; +} + diff --git a/frontend/vju_display/src/components/AudioControlModule.vue b/frontend/vju_display/src/components/AudioControlModule.vue new file mode 100644 index 0000000..65592b2 --- /dev/null +++ b/frontend/vju_display/src/components/AudioControlModule.vue @@ -0,0 +1,87 @@ + + + + + diff --git a/frontend/vju_display/src/components/LectureModule.vue b/frontend/vju_display/src/components/LectureModule.vue index 627c7cb..313c9a0 100644 --- a/frontend/vju_display/src/components/LectureModule.vue +++ b/frontend/vju_display/src/components/LectureModule.vue @@ -66,7 +66,7 @@ function publishMQTTMsg(topic: string, msg: string) { async function setLecture(pos?: String) { if (!pos) { return } - let topicPref = props.room + "/projektorji/" + props.position + "/" + let topicPref = props.room + "/projectors/" + props.position + "/" let command = '0' if (roomState.value == 0) { command = '1' @@ -75,8 +75,8 @@ async function setLecture(pos?: String) { } else { return } publishMQTTMsg((topicPref + 'set/power'), command) publishMQTTMsg((topicPref + 'platno/goto'), command == '1' ? 'DOWN' : 'UP') - publishMQTTMsg((topicPref + 'lift/move/' + (command == '1' ? 'down' : 'up') ), command) - await sleep(500) + publishMQTTMsg((topicPref + 'lift/move/' + (command == '1' ? 'down' : 'up') ), '1') + await sleep(1000) publishMQTTMsg((topicPref + 'platno/goto'), 'STOP') publishMQTTMsg((topicPref + 'lift/move/' + (command == '1' ? 'down' : 'up') ), '0') } @@ -91,6 +91,8 @@ const roomStatus = reactive({ platno_state: 'UNKNOWN', }) + + const roomState = ref(0) // OFF -> 0; ON -> 1; IN BETWEEN -> 2 @@ -115,7 +117,7 @@ watch (roomStatus, (_, _newState) => {

AKTIVNO

-

V PRIPRAVLJENOSTI

+

PRIPRAVLJENOST

POČAKAJTE

NAPAKA

+
+
POWER CONTROL
+
+ + + +
+
+ +
diff --git a/frontend/vju_display/src/components/pages/VideoPage.vue b/frontend/vju_display/src/components/pages/VideoPage.vue index 86db1ac..57ecd41 100644 --- a/frontend/vju_display/src/components/pages/VideoPage.vue +++ b/frontend/vju_display/src/components/pages/VideoPage.vue @@ -9,8 +9,8 @@ import Platno from '../Platno.vue' const props = defineProps({ room: String, }) -const _glavni_position = ref('glavni') -const _stranski_position = ref('stranski') +const _glavni_position = ref('main') +const _stranski_position = ref('side') const _test = ref('test') @@ -20,12 +20,12 @@ const _test = ref('test')

Glavni

- +

Stranski

- - + +
diff --git a/malinaConfig.toml b/malinaConfig.toml new file mode 100644 index 0000000..f3590e3 --- /dev/null +++ b/malinaConfig.toml @@ -0,0 +1,5 @@ +[global] +room = "P01" +mqttIp = "localhost" +mqttPort = "1883" +