Commit c5dd2c9a by arun.uday

v4

parent 2912f84a
......@@ -4,9 +4,15 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="530f9a40-4e97-41f4-9693-adc3b4faba7d" name="Changes" comment="v2">
<list default="true" id="530f9a40-4e97-41f4-9693-adc3b4faba7d" name="Changes" comment="v3">
<change afterPath="$PROJECT_DIR$/scripts/core/database/redis_db.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/scripts/core/handlers/add_patient_queue.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/sonarlint/issuestore/index.pb" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/sonarlint/issuestore/index.pb" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/scripts/config/api_route_config.py" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/config/api_route_config.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/conf/application.conf" beforeDir="false" afterPath="$PROJECT_DIR$/conf/application.conf" afterDir="false" />
<change beforePath="$PROJECT_DIR$/scripts/config/applications_config.py" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/config/applications_config.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/scripts/core/engine/redis_db.py" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/scripts/services/receiver_app_run.py" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/services/receiver_app_run.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
......@@ -37,8 +43,8 @@
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"SONARLINT_PRECOMMIT_ANALYSIS": "true",
"last_opened_file_path": "E:/KL projects/task10mqttreceiver2",
"settings.editor.selected.configurable": "project.propVCSSupport.DirectoryMappings"
"last_opened_file_path": "E:/KL projects/task9receiverredis",
"settings.editor.selected.configurable": "preferences.pluginManager"
}
}]]></component>
<component name="RunManager">
......@@ -88,12 +94,31 @@
<option name="project" value="LOCAL" />
<updated>1675312818891</updated>
</task>
<option name="localTasksCounter" value="3" />
<task id="LOCAL-00003" summary="v3">
<created>1675318625371</created>
<option name="number" value="00003" />
<option name="presentableId" value="LOCAL-00003" />
<option name="project" value="LOCAL" />
<updated>1675318625371</updated>
</task>
<option name="localTasksCounter" value="4" />
<servers />
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="v1" />
<MESSAGE value="v2" />
<option name="LAST_COMMIT_MESSAGE" value="v2" />
<MESSAGE value="v3" />
<option name="LAST_COMMIT_MESSAGE" value="v3" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/scripts/services/receiver_app_run.py</url>
<line>9</line>
<option name="timeStamp" value="1" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
</project>
\ No newline at end of file
......@@ -20,6 +20,7 @@ mongodb = mongodb://localhost:27017
[redis_db]
redis_host = 127.0.0.1
db_queue_doctor = 0
[encode]
encode = utf-8
......
......@@ -27,6 +27,7 @@ uvicorn_app = config.get("uvicorn", "uvicorn_app")
# redis
redis_host = config.get("redis_db", "redis_host")
db_queue_doctor = config.get("redis_db", "db_queue_doctor")
# encode
utf_encode = config.get("encode", "encode")
# connecting to the redis
import redis
from scripts.config.applications_config import redis_host
from scripts.config.applications_config import redis_host, db_queue_doctor
conn = redis.Redis(redis_host)
conn = redis.Redis(redis_host, db=db_queue_doctor)
# patient to the queue
def insert_data_redis(conn_queue, doctor, patient):
# set the patient to the doctors queue
conn_queue.set(doctor, patient)
print(doctor, " assigned to ", patient)
import functools
import paho.mqtt.client as mqtt
from fastapi import FastAPI
from scripts.config.api_route_config import index_route
from scripts.config.applications_config import mqtt_host, port, request_no, utf_encode
from scripts.core.engine.redis_db import conn
from scripts.core.database.redis_db import conn
from scripts.core.handlers.add_patient_queue import insert_data_redis
from scripts.core.handlers.reading_doctors import read_doctors
# This is the Subscriber
......@@ -21,15 +24,17 @@ def receiver():
read_doctors(conn, client_name)
# printing the messages
def on_message(client_name, userdata, msg):
print(client_name, " ", userdata)
def on_message_handler(client_name, userdata, msg):
# decoding the msg to string
print(client_name, " ", userdata)
payload_decoded = msg.payload.decode(utf_encode)
print(msg.topic, "assigned to", payload_decoded)
# add patient to the queue
insert_data_redis(conn, msg.topic, payload_decoded)
# creating the paho client for mqtt
client = mqtt.Client()
client.connect(mqtt_host, int(port), int(request_no))
client.on_connect = on_connect
client.on_message = on_message
client.on_message = functools.partial(on_message_handler)
client.loop_forever()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment