final project

This commit is contained in:
2025-02-28 09:03:50 +02:00
commit 0b9419c6d2
51 changed files with 531 additions and 0 deletions

Binary file not shown.

View File

@@ -0,0 +1,22 @@
-----BEGIN CERTIFICATE-----
MIIDqjCCApKgAwIBAgIBATANBgkqhkiG9w0BAQsFADCBiDEpMCcGA1UECgwgSEFS
VElORyBJVCBTZXJ2aWNlcyBHbWJIICBDby4gS0cxDjAMBgNVBAsMBUlULUlTMRIw
EAYDVQQHDAlFc3BlbGthbXAxDDAKBgNVBAgMA05SVzELMAkGA1UEBhMCREUxHDAa
BgNVBAMME0hBUlRJTkcgV2ViIEdhdGV3YXkwHhcNMTYxMjIxMTU0NzA0WhcNMzYx
MjIxMTU0NzA0WjCBiDEpMCcGA1UECgwgSEFSVElORyBJVCBTZXJ2aWNlcyBHbWJI
ICBDby4gS0cxDjAMBgNVBAsMBUlULUlTMRIwEAYDVQQHDAlFc3BlbGthbXAxDDAK
BgNVBAgMA05SVzELMAkGA1UEBhMCREUxHDAaBgNVBAMME0hBUlRJTkcgV2ViIEdh
dGV3YXkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCm6bFPeLYge36x
WAsif9qMKEyJtrgAhtAbRWgmMWZW3s2TUMkL9Ovi5M9jc+W0V5aGCS8ueul5o9z2
acTV9FT5DDBRXGEEMITpzGh8iRPZsFrNStk8L9oEXzjj87OE+n/gvnCe7KALzsUR
UQ+FDKLGQjMzHNTwUtadRZwm+MAP02l0izTQF7ny3zpRdco8faLvSVITkX9a6N5E
N6HfftOeoQ9xMolwielanaEbcoUKJlmV7cmAw0BjezE8CT5J0MEcaGqw6ek3pCk5
Glt7jk+JE4X3UdUB9M60P+6pgZEmpbeoRXQqIKqrS8vC0cn0RiBPcyeoBXy0sqvK
Aun+2m+DAgMBAAGjHTAbMAwGA1UdEwQFMAMBAf8wCwYDVR0PBAQDAgEGMA0GCSqG
SIb3DQEBCwUAA4IBAQBarWNg89Li73TnwQly0Pn6n+/xa4P9wfDjueot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ZvfxKXEq8lzwZz20yUMaWpu+uM8mFHQ1XKMz3DvKmvJDdvRuvjU5VfyED6W
a5s0Qv9vtpekb05Bw5f6V6HJabi/Pws3tImZdQi7XRsDvQSjOvGnsyp73xsfzkj4
JCsvXuf8M6k7rznPsE3iUm5rBLbTlb1WfTScs4PDIAxQK9o8QglQ/eD07VnHsgg9
fBPWXu7NFrT+y2QDbvDE/Mjq03l0KiAATY1IsD2kE7upKAyKiS/jF+dDyBEMqj6T
5yRVbyoI6vS4wINx21I7XsC3EzfaUs13QgGAIIgJKVYrGJwEq9ARBpqmKpyKAJwt
0UkTqGZjBYTOW8/hUNpJd07M4087PGVEUNbPBp6yrddpuVllGR3n8p296KcR6m+d
cSkKAdreXI0Cpb+KmJpOuQj1rOTRxYAnYEE4zR2nd2JptjDLcxOLgMP0naZ6g8qS
LarqnBFK6cVlpeNNg+A7Ns96PBSJoYlBd4EYqfD20he1mZVnCrmjOFZh
-----END CERTIFICATE-----

Binary file not shown.

View File

@@ -0,0 +1,21 @@
Linux CUPS drivers for POS printer
The following CUPS drivers are included here.
ctzpos-cups_1.x.x-x_i386.deb - Debian (32 bit)
ctzpos-cups_1.x.x-x_amd64.deb - Debian (64 bit)
ctzpos-cups_1.x.x-x_armhf.deb - Raspberry Pi OS (32bit)
ctzpos-cups_1.x.x-x_arm64.deb - Raspberry Pi OS (64bit)
ctzpos-cups-1.x.x-x.i586.rpm - Red Hat (32bit)
ctzpos-cups-1.x.x-x.x86_64.rpm - Red Hat (64bit)
ctzpos-cups-1.x.x-x.src.rpm - CUPS driver source code in rpm format
"deb" file is for Debian and it can be used on Ubuntu etc.
"rpm" file is for Red Hat and it can be used on CentOS, Fedora etc.
Source code is inlucded to use CUPS driver on other Linux distribution.
Basic explanation for driver compile and driver installation is on following site.
http://www.citizen-systems.co.jp/en/printer/download/driver-cups-source

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

154
app.py Normal file
View File

@@ -0,0 +1,154 @@
import rdm6300
import os, time
import logging
from gpiozero import OutputDevice
from multiprocessing import Process
import requests
import subprocess
import urllib3
import threading
import urllib.parse
urllib3.disable_warnings()
# Configure logging
logging.basicConfig(filename='./data/log.txt', level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
def config():
import config
def post_backup_data():
logging.info("Reading backup data from tag.txt...")
try:
with open("./data/tag.txt", "r") as file:
lines = file.readlines()
remaining_lines = lines[:]
for line in lines:
line = line.strip()
if line:
logging.info(f"Posting backup data: {line}")
try:
response = requests.post(line, verify=False, timeout=3)
logging.info("Request sent, awaiting response...")
response.raise_for_status() # Raise an error for bad status codes
logging.info("Data posted successfully: %s", response.text)
remaining_lines.remove(line + "\n")
except requests.exceptions.Timeout:
logging.warning("Request timed out.")
break
except requests.exceptions.RequestException as e:
logging.error("An error occurred: %s", e)
break
with open("./data/tag.txt", "w") as file:
file.writelines(remaining_lines)
logging.info("Backup data updated.")
except FileNotFoundError:
logging.warning("No backup file found.")
except Exception as e:
logging.error("An error occurred while reading the backup file: %s", e)
def check_internet_connection():
hostname = "10.76.140.17" # "https://google.com"
cmd_block_wifi = 'sudo rfkill block wifi'
cmd_unblock_wifi = 'sudo rfkill unblock wifi'
logging.info('Internet connection check loaded')
def manage_wifi_connection():
if var1 == 0:
logging.info("Internet is up! Waiting 45 minutes.")
post_backup_data()
time.sleep(2700)
else:
os.system(cmd_block_wifi)
logging.info('System is rebooting WiFi, please wait until it finishes the job 20 minutes')
time.sleep(1200) # 20 minutes
os.system(cmd_unblock_wifi)
while True:
response = os.system("ping -c 1 " + hostname)
if response == 0:
var1 = 0
manage_wifi_connection()
else:
var1 = 1
manage_wifi_connection()
# Start the internet connection check in a separate process
internet_check_process = Process(target=check_internet_connection)
internet_check_process.start()
url = "10.76.140.17/iweb_v2/index.php/traceability/production" # pentru cazul in care raspberiul nu are sistem de prezenta
# Launch Chromium with the specified URLs
subprocess.Popen(["chromium", "--test-type", "--noerrors", "--kiosk", "--start-fullscreen", "--unsafely-treat-insecure-origin-as-secure=http://10.76.140.17", url], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, stdin=subprocess.DEVNULL, start_new_session=True)
info = "0"
def post_info(info):
logging.info("Starting to post data...")
info1 = info.strip() # Remove any leading/trailing whitespace, including newlines
try:
response = requests.post(info1, verify=False, timeout=3)
logging.info("Request sent, awaiting response...")
response.raise_for_status() # Raise an error for bad status codes
logging.info("Data posted successfully: %s", response.text)
except requests.exceptions.Timeout:
logging.warning("Request timed out. Saving data to backup file.")
with open("./data/tag.txt", "a") as file: # Open in append mode
file.write(info)
logging.info("Value %s was saved to tag.txt", info)
except requests.exceptions.RequestException as e:
logging.error("An error occurred: %s", e)
with open("./data/tag.txt", "a") as file: # Open in append mode
file.write(info)
logging.info("Value %s was saved to tag.txt", info)
def post_info_thread(info):
thread = threading.Thread(target=post_info, args=(info,))
thread.start()
led1 = OutputDevice(23)
led2 = OutputDevice(24)
name = "idmasa"
logging.info(f"Variabila Id Masa A fost initializata", name)
f = open("./data/idmasa.txt", "r") # deschid fisierul
name = f.readline().strip() # citesc toate liniile
f.close() # inchid fisierul
logging.info(name)
class Reader(rdm6300.BaseReader):
global info
def card_inserted(self, card):
if card.value == 12886709:
logging.info("Inserting Config Card")
return
# config()
afisare = time.strftime("%Y-%m-%d&%H:%M:%S")
date = 'https://dataswsibiusb01.sibiusb.harting.intra/RO_Quality_PRD/api/record/' + name + '/' + str(card.value) + "/1/" + afisare + "\n"
info = date
logging.info(info)
post_info_thread(info)
led1.on()
logging.info(f"card inserted {card}")
def card_removed(self, card):
if card.value == 12886709:
logging.info("Removing Config card")
return
# config()
afisare=time.strftime("%Y-%m-%d&%H:%M:%S")
date='https://dataswsibiusb01.sibiusb.harting.intra/RO_Quality_PRD/api/record/'+name+'/'+str(card.value)+"/0/"+afisare+"\n"
info = date
logging.info(info)
post_info_thread(info)
led1.off()
logging.info("Card removed")
try:
r = Reader('/dev/ttyS0')
except:
r = Reader('/dev/ttyAMA0')
r.start()

28
cert.sh Normal file
View File

@@ -0,0 +1,28 @@
#!/bin/bash
# Instalare certificate
echo -e "\e[1;32m Copiem si instalam certificatele Harting \e[0m"
sudo mkdir /usr/local/share/ca-certificates/Harting
sudo cp -R /home/pi/Desktop/Prezenta/Files/reposytory/Harting/ /usr/local/share/ca-certificates/Harting/
sudo update-ca-certificates
sleep 3
echo -e "\e[1;32m Instalam Libnss3-tool ca sa actualizam certificatele in Browser \e[0m"
sudo apt install libnss3-tools
echo -e "\e[1;32m Libnss3-tools este instalat \e[0m"
echo -e "\e[1;32m Cream baza de date pentru certutil \e[0m"
#sudo mkdir -p $HOME/.pki/nssdb
#sudo certutil -d $HOME/.pki/nssdb -N --empty-password
echo -e "\e[1;32m Baza de date a fost creata \e[0m"
echo -e "\e[1;32m Actualizam Certificate \e[0m"
certutil -d sql:$HOME/.pki/nssdb -A -t "CT,C,C" -n HA_MWG_new_cert -i /etc/ssl/certs/HA_MWG_new_cert.pem
echo "cert 1 ok"
sleep 3
certutil -d sql:$HOME/.pki/nssdb -A -t "CT,C,C" -n HartingIssuingCA1.pem -i /etc/ssl/certs/HartingIssuingCA1.pem
echo "cert 2 Ok"
sleep 3
certutil -d sql:$HOME/.pki/nssdb -A -t "CT,C,C" -n HartingRootCA.pem -i /etc/ssl/certs/HartingRootCA.pem
echo "cert 3 ok"
echo -e "\e[1;32m Certificatele au fost instalate \e[0m"
sleep 3
certutil -d sql:$HOME/.pki/nssdb -L
sleep 3

219
config.py Executable file
View File

@@ -0,0 +1,219 @@
# config py este gandit pentru a verifica configurarile raspberiului
# verifica hostname-ul si il afiseaza
# verifica ce nume are masa si o afiseaza
# verifica daca masa este configurata cu sistem de prezenta operator
# verifica daca imprimanta este instalata corespunzator
import os, time, socket, cups, subprocess
import FreeSimpleGUI as psg
import FreeSimpleGUI as sg
from multiprocessing import Process
# import socket
host = socket.gethostname() # luam numele de host
def set_printer(): # importam codul python pentru printer
print("Cheking printer")
# acest segment acceseaza fisierul local idmas.txt si verifica ce informatii sunt acolo
# in mod normal acolo salvam numele mesei care trebuie sa corespunda cu numele imprimantei
f = open("./data/idmasa.txt","r") # deschid fisierul in care am salvat numele printerului
test = f.readlines() # citesc toate liniile
f.close()
# in cazul in care avem fisier corupt il resetam la original
try:
idmasa = test[0]
except IndexError:
idmasa = "0"
print(idmasa)
# citim lista de printere disponibila
conn = cups.Connection ()
printers = conn.getPrinters ()
printer_stat=0
for printer in printers:
print (printer, printers[printer]["device-uri"])
if printer == idmasa:
printer_stat = 1
if printer_stat == 1:
print("Printer is Ok")
else:
print("Printer is not ok")
p_Name = idmasa
print("Installing the new printer")
time.sleep(2)
cmd = "sudo /usr/sbin/lpadmin -p "+idmasa+" -E -v usb://CITIZEN/CT-S310II?serial=00000000 -m CTS310II.ppd"
os.popen(cmd)
time.sleep(2)
print("Printer Was Installed")
conn = cups.Connection()
printers = conn.getPrinters()
for printer in printers:
print(printer, printers[printer]["device-uri"])
time.sleep(1)
print("Printerwas seted to "+idmasa+"")
print("Test printer App Closed")
# partea acesata se ocupa de verificarea existentei celor doua fisiere pentru a nu avea erori
# verificam daca exista fisierul care identifica masa
path = './data/idmasa.txt'
isFile = os.path.isfile(path) #verifica existenta fisierului prin bolean Tru/false
if not isFile:
# print(path)# nu se face nimic pentru ca exista fisierul
#else:
fp = open('./data/idmasa.txt', 'w') # cream fisier
fp.write('no_config') # scriem in fisier prima line pentru a avea un punct de pornire
fp.close() # inchidem fisierul
# print("created file")
# verificam fisierul de prezenta pe baza acestuia stim daca locul de munca este configurat cu card de prezenta sau nu
path1 = './data/idmasa.txt' #verificare existenta al doilea fisier
isFile = os.path.isfile(path1)# verifica existenta fisierului
#print(path)
#urmeaza sa citim fisierele pentru a crea cateva variabile
# prima variabila este idmasa
f = open("./data/idmasa.txt","r") # deschid fisierul
name = f.readlines() # citesc toate liniile
f.close() # inchid fisierul
try:
idmasa = name[0]# se verifica daca exista informatie in text
except IndexError:
idmasa = "Initial"# daca nu exista informatie in text setam variabila
#incepem sa definim primele functii din configurare
def notokfunction(): # este functie pentru butonul cancel din formular
msg1 = "Id masa a fost actualizat la: "+ idmasa +"" ## pregatim mesajul pentru fereastra pop up
msg2 = "Slotul Pentru cartela este configurat by default" # pregatim mesajul pentru fereastra pop up
layout = [[sg.Text(msg1)], [sg.Text(msg2)], [sg.Button("Ok")]]
window = sg.Window("Configurari", layout)
while True:
event, values = window.read()
if event == "Ok" or event == sg.WIN_CLOSED:
break
window.close()
#am inchis functia notok
#functia pentru butonul ok din formular
def okfunction():
if idmasa == config1: # variabila config 1 este preluata din formular
msg1 = "Masa este setat corect: "+ idmasa +"" # se printeaza mesaj ca nu se actualizeaza id de masa
# print(msg1)
else:
f = open("./data/idmasa.txt","w") # deschidem fisierul config in mod scriere
L = config1
f.write(L) # actualizam linia cu noua valuare din config
f.close() # inchidem fisierul
msg1 = "Id masa a fost actualizat la: "+ config1 +"" # pregatim mesajul pentru fereastra pop up
#
# definim fereastra pentru ok asemena cu functia notok
layout = [[sg.Text(msg1)], [sg.Output(size=(40, 15))], [sg.Button("Ok")]]
window = sg.Window("Configurari", layout)
while True:
event, values = window.read()
# End program if user closes window or
# presses the OK button
if event == "Ok" or event == sg.WIN_CLOSED:
break
if nook == 1:
notokfunction()
time.sleep(2)
#asteptam 10 secunde si pornim functia de setare printer
set_printer()
#verificam daca hostul corespunde cu ce este in formular
time.sleep(2)
if host == host_conf:
print("Host name ok")
else:
print("Host name not ok")
time.sleep(2)
print("Update Hostname" )
cmd = "sudo hostnamectl set-hostname "+host_conf+"" # comanda sa schimbam hostnameul
os.popen(cmd)
print("Os hostname updated")
time.sleep(2)
print("System will reboot in 5 seconds")
time.sleep(1)
print("System will reboot in 4 seconds")
time.sleep(1)
print("System will reboot in 3 seconds")
time.sleep(1)
print("System will reboot in 2 seconds")
time.sleep(1)
print("System will reboot in 1 seconds")
time.sleep(3)
window.close()
# incepem initializarea feresteri ptrincipale gui
sg.theme('dark grey 9') #alegem tema dark grey
psg.set_options(font=('Arial Bold', 16)) # setam fontul
#setarile de layout
layout = [
[sg.Text('Host_Name', size=(20,1)),sg.InputText(default_text= ""+host+"" , enable_events=False)],
[sg.Text('Loc De Munca', size=(20,1)),sg.InputText(default_text=""+idmasa+"", enable_events=False)],
[sg.Button('Ok'), sg.Button('Cancel')]
]
# setam window
window = psg.Window('Form', layout, size=(800,190),finalize=True)
# citim si configuram widgetul pentru butoanele 1 si 0 din randul
while True:
nook = 0 # cream o variabila care sa ne spuna daca a fost setao butonul ok sau nu
event, values = window.read() # citim valorile intr-o lista numita values
host_conf= values[0] # atribuim primul item din lista variabilei Host config
# aceasta variabila o vom folosi pentru a scrie sa nu noul hostname
print(host_conf)
if event == sg.WIN_CLOSED or event == 'Cancel':
nook = 1 # daca se da cancel setam variabila nook la 1
break
config1 = values[1] # atribuim lui config 1 valuarea din campul Loc de munca care a fost scris cu Id masa
# pornim functi care scrie valorile config in fisiere ok function
okfunction()
# si inchidem formularul
# semnalam ca s-a terminat afisarea formularului
break
#inchidem formularul
window.close()
# daca variabila nook este 1
time.sleep(2)
os.system("sudo reboot now")

1
data/idmasa.txt Normal file
View File

@@ -0,0 +1 @@
not_config

0
data/log.txt Normal file
View File

0
data/tag.txt Normal file
View File

14
libraries.sh Normal file
View File

@@ -0,0 +1,14 @@
#!/bin/bash
#install python libraries
echo -e "\e[1;32m Incepem Instalarea Librariilor Python \e[0m"
pip3 install /home/pi/Desktop/Prezenta/Files/reposytory/six-1.16.0-py2.py3-none-any.whl -f ./ --no-index --no-deps --break-system-packages
pip3 install /home/pi/Desktop/Prezenta/Files/reposytory/PyAutoGUI-0.9.54-py3-none-any.whl -f ./ --no-index --no-deps --break-system-packages
pip3 install /home/pi/Desktop/Prezenta/Files/reposytory/pynput-1.7.6-py2.py3-none-any.whl -f ./ --no-index --no-deps --break-system-packages
pip3 install /home/pi/Desktop/Prezenta/Files/reposytory/pyserial-3.5-py2.py3-none-any.whl -f ./ --no-index --no-deps --break-system-packages --no-warn-script-location
pip3 install /home/pi/Desktop/Prezenta/Files/reposytory/python_xlib-0.31-py2.py3-none-any.whl -f ./ --no-index --no-deps --break-system-packages
pip3 install /home/pi/Desktop/Prezenta/Files/reposytory/python3_xlib-0.15-py3-none-any.whl -f ./ --no-index --no-deps --break-system-packages
pip3 install /home/pi/Desktop/Prezenta/Files/reposytory/rdm6300-0.1.1-py3-none-any.whl -f ./ --no-index --no-deps --break-system-packages
pip3 install /home/pi/Desktop/Prezenta/Files/reposytory/typing_extensions-4.11.0-py3-none-any.whl -f ./ --no-index --no-deps --break-system-packages
pip3 install /home/pi/Desktop/Prezenta/Files/reposytory/FreeSimpleGUI-5.0.0-py3-none-any.whl -f ./ --no-index --no-deps --break-system-packages
pip3 install /home/pi/Desktop/Prezenta/Files/reposytory/func_timeout-4.3.5-py3-none-any.whl -f ./ --no-index --no-deps --break-system-packages
echo -e "\e[1;32m Librariile au fost instalate cu succes \e[0m"